Merge pull request #12212 from staktrace/touchfix
Bug 1643508 - Disable touch-based pinch zooming on pdf.js.
This commit is contained in:
commit
66bbe82cc5
20
web/app.js
20
web/app.js
@ -1768,6 +1768,9 @@ const PDFViewerApplication = {
|
||||
|
||||
window.addEventListener("visibilitychange", webViewerVisibilityChange);
|
||||
window.addEventListener("wheel", webViewerWheel, { passive: false });
|
||||
window.addEventListener("touchstart", webViewerTouchStart, {
|
||||
passive: false,
|
||||
});
|
||||
window.addEventListener("click", webViewerClick);
|
||||
window.addEventListener("keydown", webViewerKeyDown);
|
||||
window.addEventListener("keyup", webViewerKeyUp);
|
||||
@ -1830,6 +1833,9 @@ const PDFViewerApplication = {
|
||||
|
||||
window.removeEventListener("visibilitychange", webViewerVisibilityChange);
|
||||
window.removeEventListener("wheel", webViewerWheel, { passive: false });
|
||||
window.removeEventListener("touchstart", webViewerTouchStart, {
|
||||
passive: false,
|
||||
});
|
||||
window.removeEventListener("click", webViewerClick);
|
||||
window.removeEventListener("keydown", webViewerKeyDown);
|
||||
window.removeEventListener("keyup", webViewerKeyUp);
|
||||
@ -2527,6 +2533,20 @@ function webViewerWheel(evt) {
|
||||
}
|
||||
}
|
||||
|
||||
function webViewerTouchStart(evt) {
|
||||
if (evt.touches.length > 1) {
|
||||
// Disable touch-based zooming, because the entire UI bits gets zoomed and
|
||||
// that doesn't look great. If we do want to have a good touch-based
|
||||
// zooming experience, we need to implement smooth zoom capability (probably
|
||||
// using a CSS transform for faster visual response, followed by async
|
||||
// re-rendering at the final zoom level) and do gesture detection on the
|
||||
// touchmove events to drive it. Or if we want to settle for a less good
|
||||
// experience we can make the touchmove events drive the existing step-zoom
|
||||
// behaviour that the ctrl+mousewheel path takes.
|
||||
evt.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function webViewerClick(evt) {
|
||||
// Avoid triggering the fallback bar when the user clicks on the
|
||||
// toolbar or sidebar.
|
||||
|
Loading…
x
Reference in New Issue
Block a user