@braccato/core 1.19.0 → 1.19.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.
- package/dist/engine.d.ts +3 -1
- package/dist/engine.js +20 -10
- package/package.json +1 -1
package/dist/engine.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ interface AnimEngineViewState {
|
|
|
31
31
|
};
|
|
32
32
|
passiveScrollAccumulatedTime: number;
|
|
33
33
|
passiveLastWallTime: number;
|
|
34
|
+
/** Where the passive drift last put the scroll, so a scroll that lands anywhere else is the reader's. */
|
|
35
|
+
passiveScrollTop: number | null;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* `Window` alone types neither `ResizeObserver` nor `DOMMatrix`: both are ambient `var`
|
|
@@ -116,7 +118,7 @@ export declare function resetScrollResume(engine: AnimationEngineInstance): void
|
|
|
116
118
|
*/
|
|
117
119
|
export declare function resumeAllAutoscroll(): void;
|
|
118
120
|
/**
|
|
119
|
-
* The user scrolled this view. Scrolls the engine itself performed are swallowed
|
|
121
|
+
* The user scrolled this view. Scrolls the engine itself performed are swallowed;
|
|
120
122
|
* a real one pauses autoscroll long enough to read where it landed, and offers the way back.
|
|
121
123
|
*
|
|
122
124
|
* @param isPassive - Whether the lyrics on screen are unsynced, and so are drifting on their own
|
package/dist/engine.js
CHANGED
|
@@ -26,6 +26,7 @@ const LYRICS_CHECK_INTERVAL_ERROR = "Error in lyrics check interval:";
|
|
|
26
26
|
const PAUSING_LYRICS_SCROLL_LOG = "Pausing Lyrics Autoscroll Due to User Scroll";
|
|
27
27
|
const USER_SCROLL_RESUME_DELAY_MS = 25000;
|
|
28
28
|
const PASSIVE_USER_SCROLL_RESUME_DELAY_MS = 5000;
|
|
29
|
+
const PASSIVE_DRIFT_SCROLL_TOLERANCE_PX = 1;
|
|
29
30
|
const LYRIC_ENDING_THRESHOLD_S = registerThemeSetting("blyrics-lyric-ending-threshold-s", 0.5);
|
|
30
31
|
const EARLY_SCROLL_CONSIDER = registerThemeSetting("blyrics-early-scroll-consider-s", 0.54);
|
|
31
32
|
const TIME_JUMP_THRESHOLD = 0.5;
|
|
@@ -134,6 +135,7 @@ export function createAnimationEngineInstance(engineDocument, engineWindow, host
|
|
|
134
135
|
},
|
|
135
136
|
passiveScrollAccumulatedTime: 0,
|
|
136
137
|
passiveLastWallTime: 0,
|
|
138
|
+
passiveScrollTop: null,
|
|
137
139
|
cachedTabRendererHeight: null,
|
|
138
140
|
cachedScrollInsets: NO_SCROLL_INSETS,
|
|
139
141
|
cachedFooterItem: null,
|
|
@@ -231,14 +233,18 @@ export function resumeAllAutoscroll() {
|
|
|
231
233
|
forEveryLiveView(resetScrollResume);
|
|
232
234
|
}
|
|
233
235
|
/**
|
|
234
|
-
* The user scrolled this view. Scrolls the engine itself performed are swallowed
|
|
236
|
+
* The user scrolled this view. Scrolls the engine itself performed are swallowed;
|
|
235
237
|
* a real one pauses autoscroll long enough to read where it landed, and offers the way back.
|
|
236
238
|
*
|
|
237
239
|
* @param isPassive - Whether the lyrics on screen are unsynced, and so are drifting on their own
|
|
238
240
|
* rather than following the song. Those resume sooner.
|
|
239
241
|
*/
|
|
240
242
|
export function noteUserScroll(engine, isPassive) {
|
|
241
|
-
if (
|
|
243
|
+
if (isPassive) {
|
|
244
|
+
if (isPassiveDriftScroll(engine))
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
else if (engine.skipScrolls > 0) {
|
|
242
248
|
engine.skipScrolls--;
|
|
243
249
|
engine.skipScrollsDecayTimes.shift();
|
|
244
250
|
return;
|
|
@@ -314,6 +320,7 @@ export function clearLyrics(engine) {
|
|
|
314
320
|
engine.lastScrollDebugContext.centers = [];
|
|
315
321
|
engine.passiveScrollAccumulatedTime = 0;
|
|
316
322
|
engine.passiveLastWallTime = 0;
|
|
323
|
+
engine.passiveScrollTop = null;
|
|
317
324
|
stopPassiveScrollLoop(engine);
|
|
318
325
|
engine.lines = [];
|
|
319
326
|
engine.cachedFooterItem = null;
|
|
@@ -2132,15 +2139,18 @@ function passiveScrollEngine(engine, isPlaying) {
|
|
|
2132
2139
|
// Phase 4: hold at top
|
|
2133
2140
|
targetScroll = 0;
|
|
2134
2141
|
}
|
|
2135
|
-
const prevScrollTop = tabRenderer.scrollTop;
|
|
2136
2142
|
tabRenderer.scrollTop = targetScroll;
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2143
|
+
engine.passiveScrollTop = tabRenderer.scrollTop;
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2146
|
+
* The drift writes the scroll every frame, and a browser folds that scroll and the reader's into one
|
|
2147
|
+
* event, so the drift's own scrolls are told apart by where they land rather than by counting them.
|
|
2148
|
+
*/
|
|
2149
|
+
function isPassiveDriftScroll(engine) {
|
|
2150
|
+
const scrollTop = engine.host.getScrollElement()?.scrollTop;
|
|
2151
|
+
return (engine.passiveScrollTop !== null &&
|
|
2152
|
+
scrollTop !== undefined &&
|
|
2153
|
+
Math.abs(scrollTop - engine.passiveScrollTop) < PASSIVE_DRIFT_SCROLL_TOLERANCE_PX);
|
|
2144
2154
|
}
|
|
2145
2155
|
/**
|
|
2146
2156
|
* Sets up a ResizeObserver on the tab renderer to cache its height.
|