akanjs 3.3.0-rc.29 → 3.3.0-rc.30
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.
- package/client/keyboardRide.ts +6 -2
- package/package.json +1 -1
package/client/keyboardRide.ts
CHANGED
|
@@ -37,9 +37,11 @@ export class KeyboardRide {
|
|
|
37
37
|
static #timer: ReturnType<typeof setTimeout> | null = null;
|
|
38
38
|
static #insets = new Map<HTMLElement, { paddingBottom: string; base: string; rise: number }>();
|
|
39
39
|
static #glides = new Map<HTMLElement, number>();
|
|
40
|
+
static #movedAt = 0;
|
|
40
41
|
|
|
41
42
|
static move(height: number, durationMs: number) {
|
|
42
43
|
if (height === KeyboardRide.#target) return;
|
|
44
|
+
KeyboardRide.#movedAt = performance.now();
|
|
43
45
|
KeyboardRide.#target = height;
|
|
44
46
|
const root = document.documentElement;
|
|
45
47
|
if (durationMs > 0) {
|
|
@@ -88,7 +90,9 @@ export class KeyboardRide {
|
|
|
88
90
|
rider.style.transform = `translateY(${drawn[idx] - laid[idx]}px)`;
|
|
89
91
|
});
|
|
90
92
|
void root.offsetHeight;
|
|
91
|
-
|
|
93
|
+
|
|
94
|
+
const late = Math.round(performance.now() - KeyboardRide.#movedAt);
|
|
95
|
+
const transition = `transform ${durationMs}ms ${nativeKeyboardEasing()} ${late > 0 ? -late : 0}ms`;
|
|
92
96
|
riders.forEach((rider, idx) => {
|
|
93
97
|
rider.style.transition = transition;
|
|
94
98
|
rider.style.transform = `translateY(${settled[idx] - laid[idx]}px)`;
|
|
@@ -152,7 +156,7 @@ export class KeyboardRide {
|
|
|
152
156
|
const from = scroller.scrollTop;
|
|
153
157
|
scroller.setAttribute(GLIDE_ATTRIBUTE, "");
|
|
154
158
|
const ease = KeyboardRide.#easeOf(nativeKeyboardEasing());
|
|
155
|
-
const startedAt =
|
|
159
|
+
const startedAt = KeyboardRide.#movedAt;
|
|
156
160
|
const step = (now: number) => {
|
|
157
161
|
const progress = durationMs > 0 ? Math.min(1, (now - startedAt) / durationMs) : 1;
|
|
158
162
|
scroller.scrollTop = from + (to - from) * ease(progress);
|