Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Re-enabling controls for mobile viewers #157

Merged
merged 2 commits into from
May 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,6 @@ const MOBILE_MAX_CANVAS_SIZE = 2949120; // ~3MP 1920x1536
* @return {void}
*/
loadUI() {
if (this.isMobile) {
return;
}

this.controls = new Controls(this.containerEl);
this.bindControlListeners();
this.initPageNumEl();
Expand Down
6 changes: 0 additions & 6 deletions src/lib/viewers/doc/__tests__/DocBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,12 +1210,6 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => {
expect(initPageNumElStub).to.be.called;
expect(docBase.controls instanceof Controls).to.be.true;
});

it('should disable controls if on a mobile browser', () => {
docBase.isMobile = true;
docBase.loadUI();
expect(docBase.controls).to.be.undefined;
});
});

describe('showPageNumInput()', () => {
Expand Down
19 changes: 4 additions & 15 deletions src/lib/viewers/image/ImageBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,12 @@ const CSS_CLASS_PANNABLE = 'pannable';
updateCursor() {
if (this.isPannable) {
this.isZoomable = false;

if (!this.isMobile) {
this.imageEl.classList.add(CSS_CLASS_PANNABLE);
this.imageEl.classList.remove(CSS_CLASS_ZOOMABLE);
}
this.imageEl.classList.add(CSS_CLASS_PANNABLE);
this.imageEl.classList.remove(CSS_CLASS_ZOOMABLE);
} else {
this.isZoomable = true;

if (!this.isMobile) {
this.imageEl.classList.remove(CSS_CLASS_PANNABLE);
this.imageEl.classList.add(CSS_CLASS_ZOOMABLE);
}
this.imageEl.classList.remove(CSS_CLASS_PANNABLE);
this.imageEl.classList.add(CSS_CLASS_ZOOMABLE);
}
}

Expand All @@ -167,11 +161,6 @@ const CSS_CLASS_PANNABLE = 'pannable';
* @return {void}
*/
loadUI() {
// Temporarily disabling controls on mobile
if (this.isMobile) {
return;
}

this.controls = new Controls(this.containerEl);
this.controls.add(__('zoom_out'), this.zoomOut, 'bp-image-zoom-out-icon', ICON_ZOOM_OUT);
this.controls.add(__('zoom_in'), this.zoomIn, 'bp-image-zoom-in-icon', ICON_ZOOM_IN);
Expand Down
5 changes: 0 additions & 5 deletions src/lib/viewers/image/ImageViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ const IMAGE_ZOOM_SCALE = 1.2;
loadUI() {
super.loadUI();

// Temporarily disabling controls on mobile
if (this.isMobile) {
return;
}

this.controls.add(__('rotate_left'), this.rotateLeft, 'bp-image-rotate-left-icon', ICON_ROTATE_LEFT);
this.controls.add(
__('enter_fullscreen'),
Expand Down
21 changes: 0 additions & 21 deletions src/lib/viewers/image/__tests__/ImageBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,6 @@ describe('lib/viewers/image/ImageBaseViewer', () => {
expect(imageBase.imageEl).to.have.class(CSS_CLASS_ZOOMABLE);
expect(imageBase.imageEl).to.not.have.class(CSS_CLASS_PANNABLE);
});

it('should update classes if using a mobile browser', () => {
imageBase.isMobile = true;
imageBase.isZoomable = true;
imageBase.isPannable = true;

imageBase.updateCursor();
expect(imageBase.isZoomable).to.have.been.false;

imageBase.isZoomable = false;
imageBase.isPannable = false;

imageBase.updateCursor();
expect(imageBase.isZoomable).to.have.been.true;
});
});

describe('startPanning()', () => {
Expand Down Expand Up @@ -222,12 +207,6 @@ describe('lib/viewers/image/ImageBaseViewer', () => {
expect(imageBase.controls).to.not.be.undefined;
expect(imageBase.controls.buttonRefs.length).to.equal(2);
});

it('should disable controls if on a mobile browser', () => {
imageBase.isMobile = true;
imageBase.loadUI();
expect(imageBase.controls).to.be.undefined;
});
});

describe('handleMouseDown()', () => {
Expand Down
11 changes: 1 addition & 10 deletions src/lib/viewers/image/__tests__/ImageViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,8 @@ describe('lib/viewers/image/ImageViewer', () => {
});

describe('loadUI()', () => {
beforeEach(() => {
image.boxAnnotationsLoaded = false;
});

it('should load UI & controls for zoom', () => {
image.boxAnnotationsLoaded = false;
image.annotator = null;

image.loadUI();
Expand All @@ -376,12 +373,6 @@ describe('lib/viewers/image/ImageViewer', () => {
expect(image.controls.buttonRefs.length).to.equal(5);
expect(image.boxAnnotationsLoaded).to.be.false;
});

it('should disable controls if on a mobile browser', () => {
image.isMobile = true;
image.loadUI();
expect(image.controls).to.be.undefined;
});
});

describe('print()', () => {
Expand Down