Skip to content

Commit be5d05a

Browse files
committed
inertia over synthetic minor fix
1 parent deab994 commit be5d05a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/modules/viewport.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ export default function Viewport(elementRoutines, buffer, element, viewportContr
187187
topPadding.height(paddingHeight);
188188
return;
189189
}
190-
const currentPosition = viewport.scrollTop();
191-
const newPosition = currentPosition - paddingHeight;
190+
const position = viewport.scrollTop();
191+
const newPosition = position - paddingHeight;
192+
viewport.synthetic = { previous: position, next: newPosition };
192193
topPadding.height(0);
193-
viewport.synthetic = { position: newPosition };
194194
viewport.scrollTop(newPosition);
195195
},
196196

src/ui-scroll.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,17 @@ angular.module('ui.scroll', [])
496496
if (!viewport.synthetic) {
497497
return;
498498
}
499-
const position = viewport.synthetic.position;
500-
if (viewport.scrollTop() !== position) {
499+
const oldPosition = viewport.synthetic.previous;
500+
const newPosition = viewport.synthetic.next;
501+
if (viewport.scrollTop() !== newPosition) {
501502
requestAnimationFrame(() => {
502-
viewport.scrollTop(position);
503+
const position = viewport.scrollTop();
504+
const diff = oldPosition - position;
505+
if (diff > 0) { // inertia over synthetic
506+
viewport.scrollTop(newPosition - diff);
507+
} else {
508+
viewport.scrollTop(newPosition);
509+
}
503510
viewport.synthetic = null;
504511
});
505512
return true;

0 commit comments

Comments
 (0)