Commit c30fa0aa authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

PDF Viewer Update: Ignore rounding error for zoom-changed event dispatch

The viewport zoom can have a non-integer value, but, currently,  when
focus passes through the zoom input, the 'zoom-changed' event is
dispatched for the integer value.

Consequently, on the blurring of the zoom input, the zoom of the PDF
content slightly changes to the nearest integer value of the viewport
zoom, even though the value in the zoom indicator does not change.

To fix this, only dispatch the zoom-change' event when the difference of
the input value and the viewport zoom value is less than 0.5.

Change-Id: I8380d148cbd3219c34c56a51af47c2e9a351efd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436856Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811754}
parent 6987ab93
...@@ -307,6 +307,12 @@ export class ViewerPdfToolbarNewElement extends PolymerElement { ...@@ -307,6 +307,12 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
if (Number.isNaN(value)) { if (Number.isNaN(value)) {
return false; return false;
} }
// The viewport can have non-integer zoom values.
if (Math.abs(this.viewportZoom * 100 - value) < 0.5) {
return false;
}
this.dispatchEvent(new CustomEvent('zoom-changed', {detail: value})); this.dispatchEvent(new CustomEvent('zoom-changed', {detail: value}));
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment