mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
fix(scroll): correctly resolve when scrolling finishes
This commit is contained in:
@ -56,11 +56,16 @@ export class ScrollView {
|
||||
|
||||
return new Promise(resolve => {
|
||||
let startTime: number;
|
||||
let attempts = 0;
|
||||
|
||||
// scroll loop
|
||||
function step() {
|
||||
if (!self._el || !self.isPlaying) {
|
||||
return resolve();
|
||||
attempts++;
|
||||
|
||||
if (!self._el || !self.isPlaying || attempts > 200) {
|
||||
self.isPlaying = false;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
let time = Math.min(1, ((Date.now() - startTime) / duration));
|
||||
@ -74,10 +79,10 @@ export class ScrollView {
|
||||
}
|
||||
|
||||
if (fromX != x) {
|
||||
self._el.scrollLeft = Math.round((easedT * (x - fromX)) + fromX);
|
||||
self._el.scrollLeft = Math.floor((easedT * (x - fromX)) + fromX);
|
||||
}
|
||||
|
||||
if (time < 1 && self.isPlaying) {
|
||||
if (easedT < 1) {
|
||||
raf(step);
|
||||
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user