Skip to content

Commit

Permalink
Fix: Disable zoom buttons during zoom, fixes #456
Browse files Browse the repository at this point in the history
  • Loading branch information
EricHanLiu committed Aug 30, 2018
1 parent b4a1186 commit adefeca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
13 changes: 12 additions & 1 deletion source/js/viewer-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default class ViewerCore
viewport: null, // Object caching the viewport dimensions
viewportElement: null,
viewportObject: null,
zoomDuration: 600
zoomDuration: 400
};

this.settings = createSettingsView([options, this.viewerState]);
Expand Down Expand Up @@ -700,6 +700,17 @@ export default class ViewerCore
}
});

// Deactivate zoom buttons while zooming
let zoomInButton = document.getElementById(this.settings.selector + 'zoom-in-button');
let zoomOutButton = document.getElementById(this.settings.selector + 'zoom-out-button');
zoomInButton.disabled = true;
zoomOutButton.disabled = true;
setTimeout(() =>
{
zoomInButton.disabled = false;
zoomOutButton.disabled = false;
}, this.settings.zoomDuration);

// Send off the zoom level did change event.
this.publish("ZoomLevelDidChange", newZoomLevel);

Expand Down
14 changes: 3 additions & 11 deletions test/navigation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,10 @@ describe('Navigation', function ()
{
Diva.Events.subscribe('ViewerDidLoad', function (settings)
{
for (var i = 0; i < 5; i++)
{
el(settings.selector + 'zoom-out-button').click();
}

assertZoomIs(0, this, 'zoom buttons');

for (i = 0; i < 5; i++)
{
el(settings.selector + 'zoom-in-button').click();
}
el(settings.selector + 'zoom-out-button').click();
assertZoomIs(4, this, 'zoom buttons');

el(settings.selector + 'zoom-in-button').click();
assertZoomIs(5, this, 'zoom buttons');

done();
Expand Down

0 comments on commit adefeca

Please sign in to comment.