Skip to content

Commit dec9f92

Browse files
committed
Enhancement: Remove Legacy Scroll Prediction Heuristics from Grid ScrollManager (#9389)
- Removed legacy velocity and acceleration tracking properties (`lastScrollTime`, `lastScrollTop`, `scrollAcceleration`, `scrollVelocity`). - Simplified `onBodyScroll`, `onBodyScrollEnd`, and `syncGridBody` methods to directly sync the actual `scrollTop` state. - The obsolete kinematic equation heuristics are fully replaced by the deterministic `GridRowScrollPinning` addon.
1 parent 0a29701 commit dec9f92

1 file changed

Lines changed: 4 additions & 66 deletions

File tree

src/grid/ScrollManager.mjs

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import Base from '../core/Base.mjs';
2-
import Performance from '../util/Performance.mjs';
1+
import Base from '../core/Base.mjs';
32

43
/**
54
* @class Neo.grid.ScrollManager
@@ -64,30 +63,6 @@ class ScrollManager extends Base {
6463
*/
6564
gridContainer = null
6665

67-
/**
68-
* @member {Number} lastScrollTime=0
69-
* @protected
70-
*/
71-
lastScrollTime = 0
72-
73-
/**
74-
* @member {Number} lastScrollTop=0
75-
* @protected
76-
*/
77-
lastScrollTop = 0
78-
79-
/**
80-
* @member {Number} scrollAcceleration=0 (px/ms^2)
81-
* @protected
82-
*/
83-
scrollAcceleration = 0
84-
85-
/**
86-
* @member {Number} scrollVelocity=0 (px/ms)
87-
* @protected
88-
*/
89-
scrollVelocity = 0
90-
9166
/**
9267
* @param {Boolean} value
9368
* @param {Boolean} oldValue
@@ -142,25 +117,7 @@ class ScrollManager extends Base {
142117
* @protected
143118
*/
144119
onBodyScroll({scrollTop}) {
145-
let me = this,
146-
now = performance.now();
147-
148-
if (me.lastScrollTime > 0) {
149-
let dt = now - me.lastScrollTime;
150-
// dt < 100 ensures we don't calculate insane velocities from old, stale scrolls
151-
if (dt > 0 && dt < 100) {
152-
let newVelocity = (scrollTop - me.lastScrollTop) / dt;
153-
154-
if (me.scrollVelocity !== 0) {
155-
me.scrollAcceleration = (newVelocity - me.scrollVelocity) / dt;
156-
}
157-
158-
me.scrollVelocity = newVelocity;
159-
}
160-
}
161-
162-
me.lastScrollTime = now;
163-
me.lastScrollTop = scrollTop;
120+
let me = this;
164121

165122
me.scrollTop = scrollTop;
166123
me.gridBody.isScrolling = true;
@@ -174,12 +131,8 @@ class ScrollManager extends Base {
174131
*/
175132
onBodyScrollEnd() {
176133
let me = this;
177-
134+
178135
me.gridBody.isScrolling = false;
179-
me.lastScrollTime = 0;
180-
me.scrollAcceleration = 0;
181-
me.scrollVelocity = 0;
182-
183136
me.syncGridBody()
184137
}
185138

@@ -208,26 +161,11 @@ class ScrollManager extends Base {
208161
let me = this,
209162
body = me.gridBody;
210163

211-
let rtt = Performance.getAverage('grid.scroll:' + body.id) || 16,
212-
gen = Performance.getAverage('grid.createViewData:' + body.id) || 0,
213-
totalLag = rtt + gen,
214-
predictedScrollTop = me.scrollTop;
215-
216-
// Kinematic equation: d = v*t + 0.5*a*t^2
217-
// Only predict on definitive drags, not single wheel clicks
218-
if (Math.abs(me.scrollVelocity) > 0.5) {
219-
// We cap totalLag to 64ms (max ~4 frames) to prevent insane predictions if a thread hangs
220-
let boundedLag = Math.min(totalLag, 64),
221-
distance = (me.scrollVelocity * boundedLag) + (0.5 * me.scrollAcceleration * boundedLag * boundedLag);
222-
223-
predictedScrollTop = Math.max(0, me.scrollTop + distance);
224-
}
225-
226164
body.skipCreateViewData = true;
227165

228166
body.set({
229167
scrollLeft: me.scrollLeft,
230-
scrollTop : predictedScrollTop
168+
scrollTop : me.scrollTop
231169
});
232170

233171
body.skipCreateViewData = false;

0 commit comments

Comments
 (0)