Merge pull request #13140 from Snuffleupagus/GrabToPan-cleanup

[GrabToPan] Remove more IE-specific code, and remove *unconditional* browser sniffing
This commit is contained in:
Tim van der Meij 2021-03-26 21:28:12 +01:00 committed by GitHub
commit 0b6b8ef42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,16 +192,6 @@ let matchesSelector;
return matchesSelector; // If found, then truthy, and [].some() ends.
});
// Browser sniffing because it's impossible to feature-detect
// whether event.which for onmousemove is reliable
const isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
const chrome = window.chrome;
const isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
// ^ Chrome 15+ ^ Opera 15+
const isSafari6plus =
/Apple/.test(navigator.vendor) &&
/Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
/**
* Whether the left mouse is not pressed.
* @param event {MouseEvent}
@ -209,17 +199,29 @@ const isSafari6plus =
* False if unsure or if the left mouse button is pressed.
*/
function isLeftMouseReleased(event) {
if ("buttons" in event && isNotIEorIsIE10plus) {
if ("buttons" in event) {
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-buttons
// Firefox 15+
// Internet Explorer 10+
// Chrome 43+
// Safari 11.1+
return !(event.buttons & 1);
}
if (isChrome15OrOpera15plus || isSafari6plus) {
// Chrome 14+
// Opera 15+
// Safari 6.0+
return event.which === 0;
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
// Browser sniffing because it's impossible to feature-detect
// whether event.which for onmousemove is reliable.
const chrome = window.chrome;
const isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
// ^ Chrome 15+ ^ Opera 15+
const isSafari6plus =
/Apple/.test(navigator.vendor) &&
/Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
if (isChrome15OrOpera15plus || isSafari6plus) {
// Chrome 14+
// Opera 15+
// Safari 6.0+
return event.which === 0;
}
}
return false;
}