Merge pull request #11558 from Snuffleupagus/GrabToPan-eslint

Remove the `eslint-disable no-var` rule from the `web/grab_to_pan.js` file
This commit is contained in:
Tim van der Meij 2020-02-02 13:34:34 +01:00 committed by GitHub
commit 4d5aa99c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
/** /**
* Construct a GrabToPan instance for a given HTML element. * Construct a GrabToPan instance for a given HTML element.
@ -42,7 +41,7 @@ function GrabToPan(options) {
// This overlay will be inserted in the document when the mouse moves during // This overlay will be inserted in the document when the mouse moves during
// a grab operation, to ensure that the cursor has the desired appearance. // a grab operation, to ensure that the cursor has the desired appearance.
var overlay = (this.overlay = document.createElement("div")); const overlay = (this.overlay = document.createElement("div"));
overlay.className = "grab-to-pan-grabbing"; overlay.className = "grab-to-pan-grabbing";
} }
GrabToPan.prototype = { GrabToPan.prototype = {
@ -133,7 +132,7 @@ GrabToPan.prototype = {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
var focusedElement = document.activeElement; const focusedElement = document.activeElement;
if (focusedElement && !focusedElement.contains(event.target)) { if (focusedElement && !focusedElement.contains(event.target)) {
focusedElement.blur(); focusedElement.blur();
} }
@ -148,10 +147,10 @@ GrabToPan.prototype = {
this._endPan(); this._endPan();
return; return;
} }
var xDiff = event.clientX - this.clientXStart; const xDiff = event.clientX - this.clientXStart;
var yDiff = event.clientY - this.clientYStart; const yDiff = event.clientY - this.clientYStart;
var scrollTop = this.scrollTopStart - yDiff; const scrollTop = this.scrollTopStart - yDiff;
var scrollLeft = this.scrollLeftStart - xDiff; const scrollLeft = this.scrollLeftStart - xDiff;
if (this.element.scrollTo) { if (this.element.scrollTo) {
this.element.scrollTo({ this.element.scrollTo({
top: scrollTop, top: scrollTop,
@ -180,9 +179,9 @@ GrabToPan.prototype = {
}; };
// Get the correct (vendor-prefixed) name of the matches method. // Get the correct (vendor-prefixed) name of the matches method.
var matchesSelector; let matchesSelector;
["webkitM", "mozM", "msM", "oM", "m"].some(function(prefix) { ["webkitM", "mozM", "msM", "oM", "m"].some(function(prefix) {
var name = prefix + "atches"; let name = prefix + "atches";
if (name in document.documentElement) { if (name in document.documentElement) {
matchesSelector = name; matchesSelector = name;
} }
@ -195,11 +194,11 @@ var matchesSelector;
// Browser sniffing because it's impossible to feature-detect // Browser sniffing because it's impossible to feature-detect
// whether event.which for onmousemove is reliable // whether event.which for onmousemove is reliable
var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9; const isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
var chrome = window.chrome; const chrome = window.chrome;
var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app); const isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
// ^ Chrome 15+ ^ Opera 15+ // ^ Chrome 15+ ^ Opera 15+
var isSafari6plus = const isSafari6plus =
/Apple/.test(navigator.vendor) && /Apple/.test(navigator.vendor) &&
/Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent); /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);