@braccato/core 1.9.0 → 1.10.0
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/README.md +14 -0
- package/dist/README.md +14 -0
- package/dist/engine.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,20 @@ stylesheet must not be able to configure the module by accident. An empty theme
|
|
|
150
150
|
back to its default. The stylesheet itself goes into the document head under the
|
|
151
151
|
`blyrics-custom-style` id.
|
|
152
152
|
|
|
153
|
+
A comment setting holds one value for every view in the bundle. The target scroll position can
|
|
154
|
+
also be set per view: when `--blyrics-target-scroll-pos-ratio` resolves on `.blyrics-container`, it
|
|
155
|
+
wins over `blyrics-target-scroll-pos-ratio`, so an ordinary selector scopes it to one view. It takes
|
|
156
|
+
a unitless number, clamped to `0` to `1`; anything else falls back to the comment setting. Like the
|
|
157
|
+
other custom properties the module reads, it is read once per theme, so the selector has to match
|
|
158
|
+
before the theme is applied.
|
|
159
|
+
|
|
160
|
+
```css
|
|
161
|
+
/* blyrics-target-scroll-pos-ratio = 0.5; */
|
|
162
|
+
.pip-view .blyrics-container {
|
|
163
|
+
--blyrics-target-scroll-pos-ratio: 0.37;
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
153
167
|
### Autoscroll grouping and animation
|
|
154
168
|
|
|
155
169
|
`blyrics-early-scroll-consider-s` is a comment setting with an independent default of `0.54`
|
package/dist/README.md
CHANGED
|
@@ -150,6 +150,20 @@ stylesheet must not be able to configure the module by accident. An empty theme
|
|
|
150
150
|
back to its default. The stylesheet itself goes into the document head under the
|
|
151
151
|
`blyrics-custom-style` id.
|
|
152
152
|
|
|
153
|
+
A comment setting holds one value for every view in the bundle. The target scroll position can
|
|
154
|
+
also be set per view: when `--blyrics-target-scroll-pos-ratio` resolves on `.blyrics-container`, it
|
|
155
|
+
wins over `blyrics-target-scroll-pos-ratio`, so an ordinary selector scopes it to one view. It takes
|
|
156
|
+
a unitless number, clamped to `0` to `1`; anything else falls back to the comment setting. Like the
|
|
157
|
+
other custom properties the module reads, it is read once per theme, so the selector has to match
|
|
158
|
+
before the theme is applied.
|
|
159
|
+
|
|
160
|
+
```css
|
|
161
|
+
/* blyrics-target-scroll-pos-ratio = 0.5; */
|
|
162
|
+
.pip-view .blyrics-container {
|
|
163
|
+
--blyrics-target-scroll-pos-ratio: 0.37;
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
153
167
|
### Autoscroll grouping and animation
|
|
154
168
|
|
|
155
169
|
`blyrics-early-scroll-consider-s` is a comment setting with an independent default of `0.54`
|
package/dist/engine.js
CHANGED
|
@@ -1116,6 +1116,11 @@ function getCSSBoolean(engine, lyricsElement, property, fallback) {
|
|
|
1116
1116
|
function getCSSOffset(engine, lyricsElement, property, fallback) {
|
|
1117
1117
|
return Math.max(0, Math.min(1, getCSSNumber(engine, lyricsElement, property, fallback)));
|
|
1118
1118
|
}
|
|
1119
|
+
// The comment setting is shared by every view in a bundle; the custom property lets a theme scope it to one.
|
|
1120
|
+
function getTargetScrollRatio(engine, lyricsElement) {
|
|
1121
|
+
const scoped = Number.parseFloat(getCSSValue(engine, lyricsElement, "--blyrics-target-scroll-pos-ratio", ""));
|
|
1122
|
+
return Number.isFinite(scoped) ? Math.max(0, Math.min(1, scoped)) : SCROLL_POS_OFFSET_RATIO.getNumberValue();
|
|
1123
|
+
}
|
|
1119
1124
|
// Compose the glow filter so the color stays an unresolved var(--blyrics-glow-color).
|
|
1120
1125
|
// Reading a fully composed --blyrics-highlight-glow-filter-* off the container resolves the
|
|
1121
1126
|
// nested color there, which would defeat per-word overrides like
|
|
@@ -1989,7 +1994,7 @@ export function tickView(engine, currentTime, options) {
|
|
|
1989
1994
|
activeElems.push(lines[0]);
|
|
1990
1995
|
}
|
|
1991
1996
|
// Offset so lyrics appear towards the center of the screen.
|
|
1992
|
-
const scrollPosOffset = tabRendererHeight *
|
|
1997
|
+
const scrollPosOffset = tabRendererHeight * getTargetScrollRatio(engine, lyricsElement);
|
|
1993
1998
|
let lastActiveLyric = activeElems[activeElems.length - 1];
|
|
1994
1999
|
let lyricPositions = activeElems
|
|
1995
2000
|
.filter((lineData, index) => {
|
|
@@ -2172,7 +2177,7 @@ function applyScrollPadding(engine) {
|
|
|
2172
2177
|
if (!lyricsElement || !tabRenderer)
|
|
2173
2178
|
return;
|
|
2174
2179
|
const tabRendererHeight = tabRenderer.getBoundingClientRect().height;
|
|
2175
|
-
const scrollPosOffsetRatio =
|
|
2180
|
+
const scrollPosOffsetRatio = getTargetScrollRatio(engine, lyricsElement);
|
|
2176
2181
|
const currentPaddingBottom = Number.parseFloat(engine.window.getComputedStyle(lyricsElement).paddingBottom) || 0;
|
|
2177
2182
|
const lyricsHeightWithoutBottomPadding = Math.max(0, lyricsElement.scrollHeight - currentPaddingBottom);
|
|
2178
2183
|
const lyricLines = lyricsElement.querySelectorAll(`:scope > .${LINE_CLASS}`);
|