Work around for scrollBy() after scrollTo() does not work
This commit is contained in:
parent
4a2b2e6134
commit
b9d41333c1
1 changed files with 8 additions and 15 deletions
|
@ -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() {
|
||||||
|
|
Reference in a new issue