ngx-kit 9.2.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2441,6 +2441,7 @@ class AutoScroller {
|
|
|
2441
2441
|
/** Document the pointer coordinates (`update(x, y)`) are expressed in. */
|
|
2442
2442
|
pointerDoc;
|
|
2443
2443
|
speed = { x: 0, y: 0 };
|
|
2444
|
+
carry = { x: 0, y: 0 };
|
|
2444
2445
|
onTick;
|
|
2445
2446
|
edge;
|
|
2446
2447
|
maxSpeed;
|
|
@@ -2488,6 +2489,7 @@ class AutoScroller {
|
|
|
2488
2489
|
this.win?.cancelAnimationFrame(this.raf);
|
|
2489
2490
|
this.raf = 0;
|
|
2490
2491
|
this.speed = { x: 0, y: 0 };
|
|
2492
|
+
this.carry = { x: 0, y: 0 };
|
|
2491
2493
|
this.onTick = undefined;
|
|
2492
2494
|
this.win = undefined;
|
|
2493
2495
|
this.pointerDoc = undefined;
|
|
@@ -2498,14 +2500,21 @@ class AutoScroller {
|
|
|
2498
2500
|
return;
|
|
2499
2501
|
}
|
|
2500
2502
|
const container = this.container;
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2503
|
+
// Edge speed is measured in viewport pixels; an element's scrollLeft/Top are local to it.
|
|
2504
|
+
const local = isWindow(container) ? this.speed : viewportDeltaToLocal(container, this.speed);
|
|
2505
|
+
// Browsers snap scroll offsets to whole pixels, so a slow speed (< 1px/frame, i.e. when the
|
|
2506
|
+
// pointer has just entered the edge zone) would never move anything. Carry the remainder.
|
|
2507
|
+
this.carry.x += local.x;
|
|
2508
|
+
this.carry.y += local.y;
|
|
2509
|
+
const dx = Math.trunc(this.carry.x);
|
|
2510
|
+
const dy = Math.trunc(this.carry.y);
|
|
2511
|
+
this.carry.x -= dx;
|
|
2512
|
+
this.carry.y -= dy;
|
|
2513
|
+
if (dx || dy) {
|
|
2514
|
+
// `behavior: 'instant'` matters: with `scroll-behavior: smooth` on <html> or on the scroller
|
|
2515
|
+
// (very common in apps) every per-frame scroll would start a new animation that cancels the
|
|
2516
|
+
// previous one, and the list would not move at all.
|
|
2517
|
+
container.scrollBy({ left: dx, top: dy, behavior: 'instant' });
|
|
2509
2518
|
}
|
|
2510
2519
|
// Pointer ثابت مانده ولی محتوا اسکرول شده؛
|
|
2511
2520
|
// بنابراین موقعیت placeholder/sort را دوباره محاسبه کن.
|