Use Element.scrollTo
unconditionally in the GrabToPan
class
According to the MDN compatibility data this is available in all browsers that we currently support; please see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo#browser_compatibility
This commit is contained in:
parent
4f82dd3932
commit
d329267926
@ -140,18 +140,12 @@ class GrabToPan {
|
|||||||
}
|
}
|
||||||
const xDiff = event.clientX - this.clientXStart;
|
const xDiff = event.clientX - this.clientXStart;
|
||||||
const yDiff = event.clientY - this.clientYStart;
|
const yDiff = event.clientY - this.clientYStart;
|
||||||
const scrollTop = this.scrollTopStart - yDiff;
|
|
||||||
const scrollLeft = this.scrollLeftStart - xDiff;
|
|
||||||
if (this.element.scrollTo) {
|
|
||||||
this.element.scrollTo({
|
this.element.scrollTo({
|
||||||
top: scrollTop,
|
top: this.scrollTopStart - yDiff,
|
||||||
left: scrollLeft,
|
left: this.scrollLeftStart - xDiff,
|
||||||
behavior: "instant",
|
behavior: "instant",
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.element.scrollTop = scrollTop;
|
|
||||||
this.element.scrollLeft = scrollLeft;
|
|
||||||
}
|
|
||||||
if (!this.overlay.parentNode) {
|
if (!this.overlay.parentNode) {
|
||||||
document.body.append(this.overlay);
|
document.body.append(this.overlay);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user