Skip to content

Commit

Permalink
Chore: Re-enabling controls for mobile viewers (#157)
Browse files Browse the repository at this point in the history
* Chore: Re-enabling controls for mobile viewers

* Chore: Unit tests
  • Loading branch information
pramodsum authored and Jeremy Press committed May 30, 2017
1 parent b292666 commit a9e1c52
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 61 deletions.
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

0 comments on commit a9e1c52

Please sign in to comment.