Skip to content

Commit

Permalink
chore(log): Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze Xiao committed Jul 13, 2020
1 parent abb3146 commit 307d6f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const VIEWER_EVENT = {
default: 'viewerevent', // The default viewer event.
download: 'download', // Begin downloading the file.
error: 'error', // When an error occurs.
imageZoomClick: 'imagezoomclick', // When image is clicked directly to zoom/reset
load: 'load', // Preview is finished loading.
mediaEndAutoplay: 'mediaendautoplay', // Media playback has completed, with autoplay enabled.
metric: 'viewermetric', // A viewer metric.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/viewers/image/ImageBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,12 @@ class ImageBaseViewer extends BaseViewer {
if (!this.isPannable && this.isZoomable) {
// If the mouse up was not due to panning, and the image is zoomable, then zoom in.
this.zoom('in');
this.emitMetric(VIEWER_EVENT.imageZoomClick, 'in');
this.emitMetric('zoom', 'imageZoomInClick');
} else if (!this.didPan) {
// If the mouse up was not due to ending of panning, then assume it was a regular
// click mouse up. In that case reset the image size, mimicking single-click-unzoom.
this.zoom('reset');
this.emitMetric(VIEWER_EVENT.imageZoomClick, 'reset');
this.emitMetric('zoom', 'imageZoomResetClick');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/viewers/image/__tests__/ImageBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ describe('lib/viewers/image/ImageBaseViewer', () => {
imageBase.isZoomable = true;
imageBase.handleMouseUp(event);
expect(stubs.zoom).to.have.been.calledWith('in');
expect(stubs.emitMetric).to.be.calledWith('imagezoomclick', 'in');
expect(stubs.emitMetric).to.be.calledWith('zoom', 'imageZoomInClick');
});

it('should reset zoom if mouseup was not due to end of panning', () => {
Expand All @@ -367,7 +367,7 @@ describe('lib/viewers/image/ImageBaseViewer', () => {
imageBase.didPan = false;
imageBase.handleMouseUp(event);
expect(stubs.zoom).to.have.been.calledWith('reset');
expect(stubs.emitMetric).to.be.calledWith('imagezoomclick', 'reset');
expect(stubs.emitMetric).to.be.calledWith('zoom', 'imageZoomResetClick');
});

it('should not zoom if mouse up was due to end of panning', () => {
Expand Down

0 comments on commit 307d6f5

Please sign in to comment.