@braccato/core
Advanced tools
+8
-1
@@ -425,4 +425,11 @@ // A custom element over the renderer, so a page mounts synchronized lyrics by writing a tag rather | ||
| return; | ||
| // The rate a bound media element is playing at is the element's to report, the same way the | ||
| // clock is, so it overrides what the consumer wrote for exactly as long as the binding lasts. | ||
| const boundRate = this.#media === null ? undefined : this.#media.playbackRate; | ||
| // The play state last, so a consumer writing plain JavaScript cannot answer that question twice. | ||
| renderer.tick(this.#currentTimeS, { ...this.#tickOptions, isPlaying: this.#playing }); | ||
| renderer.tick(this.#currentTimeS, { | ||
| ...this.#tickOptions, | ||
| ...(boundRate === undefined ? {} : { playbackRate: boundRate }), | ||
| isPlaying: this.#playing, | ||
| }); | ||
| } | ||
@@ -429,0 +436,0 @@ #upgradeProperty(name) { |
+1
-0
@@ -59,2 +59,3 @@ import type { LineData } from "./inject.js"; | ||
| passiveScrollEnabled: boolean; | ||
| playbackRate: number; | ||
| passiveRAFId: number | null; | ||
@@ -61,0 +62,0 @@ pendingLyricsUpdateFrame: number | null; |
+7
-1
@@ -84,3 +84,3 @@ # @braccato/core | ||
| | `playing` | `playing` | `boolean` | `false` | A paused view animates differently from a playing one. | | ||
| | `tickOptions` | | `ElementTickOptions` | `{}` | The rest of a tick: four offsets taken off the clock before it is matched, whether passive scrolling is on, and when the clock was sampled. | | ||
| | `tickOptions` | | `ElementTickOptions` | `{}` | The rest of a tick: four offsets taken off the clock before it is matched, whether passive scrolling is on, when the clock was sampled, and the rate the song is playing at. | | ||
| | `theme` | `theme` | `string` | `""` | A compiled stylesheet. See Theming. | | ||
@@ -260,2 +260,8 @@ | `host` | | `Partial<LyricsRendererHost>` | `{}` | Overrides for what the renderer asks of its surroundings. Every member has a default. Writing it while connected rebuilds the view. | | ||
| The rate is read off the media element too, and passed on as `tickOptions.playbackRate`, so a song at | ||
| half or double speed animates at half or double speed rather than sweeping at 1x and being corrected | ||
| on the next tick. A consumer driving the clock itself sets that option instead. Only the animations | ||
| that follow the song are scaled: a line's exit, a word's fade and the scroll between lines keep the | ||
| timing the theme asked for at every rate. | ||
| A reading the media element has not refreshed yet is carried forward at the playback rate it was | ||
@@ -262,0 +268,0 @@ taken at, capped at 100ms of frame time. That cap is what covers a stall: the view runs at most 100ms |
+7
-0
@@ -31,2 +31,9 @@ import type { Lyric, LyricPart, LyricSyncType } from "@braccato/types"; | ||
| passiveScrollEnabled?: boolean; | ||
| /** | ||
| * How fast the song moves through its own timeline, as a multiple of real time. Defaults to 1, and | ||
| * zero or less reads as 1 because `isPlaying` is what says a song is stopped. Scales the animations | ||
| * that follow the song; a line's exit, a word's fade and the scroll between lines are the | ||
| * interface's own gestures and keep the timing the theme asked for at every rate. | ||
| */ | ||
| playbackRate?: number; | ||
| } | ||
@@ -33,0 +40,0 @@ /** |
+1
-1
| { | ||
| "name": "@braccato/core", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", | ||
| "description": "Synchronized lyrics renderer with word-by-word animations", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+7
-1
@@ -84,3 +84,3 @@ # @braccato/core | ||
| | `playing` | `playing` | `boolean` | `false` | A paused view animates differently from a playing one. | | ||
| | `tickOptions` | | `ElementTickOptions` | `{}` | The rest of a tick: four offsets taken off the clock before it is matched, whether passive scrolling is on, and when the clock was sampled. | | ||
| | `tickOptions` | | `ElementTickOptions` | `{}` | The rest of a tick: four offsets taken off the clock before it is matched, whether passive scrolling is on, when the clock was sampled, and the rate the song is playing at. | | ||
| | `theme` | `theme` | `string` | `""` | A compiled stylesheet. See Theming. | | ||
@@ -260,2 +260,8 @@ | `host` | | `Partial<LyricsRendererHost>` | `{}` | Overrides for what the renderer asks of its surroundings. Every member has a default. Writing it while connected rebuilds the view. | | ||
| The rate is read off the media element too, and passed on as `tickOptions.playbackRate`, so a song at | ||
| half or double speed animates at half or double speed rather than sweeping at 1x and being corrected | ||
| on the next tick. A consumer driving the clock itself sets that option instead. Only the animations | ||
| that follow the song are scaled: a line's exit, a word's fade and the scroll between lines keep the | ||
| timing the theme asked for at every rate. | ||
| A reading the media element has not refreshed yet is carried forward at the playback rate it was | ||
@@ -262,0 +268,0 @@ taken at, capped at 100ms of frame time. That cap is what covers a stall: the view runs at most 100ms |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
287627
1.15%5214
0.91%305
2.01%0
-100%