Work around for scrollBy() after scrollTo() does not work

jh-changes
Shin'ya Ueoka 6 years ago
parent 4a2b2e6134
commit b9d41333c1
  1. 23
      src/content/scrolls.js

@ -62,29 +62,22 @@ class Scroller {
} }
scrollTo(x, y) { scrollTo(x, y) {
let behavior = this.smooth ? 'smooth' : 'auto'; if (!this.smooth) {
this.element.scrollTo(x, y);
return;
}
this.element.scrollTo({ this.element.scrollTo({
left: x, left: x,
top: y, top: y,
behavior: behavior, behavior: 'smooth',
}); });
if (!this.smooth) {
return;
}
this.prepareReset(); this.prepareReset();
} }
scrollBy(x, y) { scrollBy(x, y) {
let behavior = this.smooth ? 'smooth' : 'auto'; let left = this.element.scrollLeft + x;
this.element.scrollBy({ let top = this.element.scrollTop + y;
left: x, this.scrollTo(left, top);
top: y,
behavior: behavior,
});
if (!this.smooth) {
return;
}
this.prepareReset();
} }
prepareReset() { prepareReset() {