@mattebox/player 0.6.0 → 0.7.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/dist/cdn/mattebox-player.min.js +3 -435
- package/dist/controls/airplay.js +28 -44
- package/dist/controls/airplay.js.map +1 -1
- package/dist/controls/chapters.d.ts +22 -11
- package/dist/controls/chapters.d.ts.map +1 -1
- package/dist/controls/chapters.js +87 -73
- package/dist/controls/chapters.js.map +1 -1
- package/dist/controls/cues.d.ts +0 -22
- package/dist/controls/cues.d.ts.map +1 -1
- package/dist/controls/cues.js +161 -191
- package/dist/controls/cues.js.map +1 -1
- package/dist/controls/fullscreen.js +52 -70
- package/dist/controls/fullscreen.js.map +1 -1
- package/dist/controls/icons.d.ts +1 -1
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +46 -70
- package/dist/controls/icons.js.map +1 -1
- package/dist/controls/menu.d.ts +7 -4
- package/dist/controls/menu.d.ts.map +1 -1
- package/dist/controls/menu.js +241 -223
- package/dist/controls/menu.js.map +1 -1
- package/dist/controls/pip.js +35 -49
- package/dist/controls/pip.js.map +1 -1
- package/dist/controls/ranges.js +42 -37
- package/dist/controls/ranges.js.map +1 -1
- package/dist/controls/session.d.ts +6 -1
- package/dist/controls/session.d.ts.map +1 -1
- package/dist/controls/session.js +41 -26
- package/dist/controls/session.js.map +1 -1
- package/dist/controls/slider.d.ts +2 -2
- package/dist/controls/slider.d.ts.map +1 -1
- package/dist/controls/slider.js +151 -159
- package/dist/controls/slider.js.map +1 -1
- package/dist/controls/time.js +17 -17
- package/dist/controls/time.js.map +1 -1
- package/dist/dom.d.ts +6 -0
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +28 -19
- package/dist/dom.js.map +1 -1
- package/dist/element-entry.js +9 -6
- package/dist/element-entry.js.map +1 -1
- package/dist/element.d.ts +4 -2
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +384 -443
- package/dist/element.js.map +1 -1
- package/dist/elements/airplay-button.js +51 -53
- package/dist/elements/airplay-button.js.map +1 -1
- package/dist/elements/audio-menu.js +62 -63
- package/dist/elements/audio-menu.js.map +1 -1
- package/dist/elements/chapters-menu.d.ts.map +1 -1
- package/dist/elements/chapters-menu.js +75 -65
- package/dist/elements/chapters-menu.js.map +1 -1
- package/dist/elements/component.d.ts +1 -1
- package/dist/elements/component.d.ts.map +1 -1
- package/dist/elements/component.js +86 -89
- package/dist/elements/component.js.map +1 -1
- package/dist/elements/control-bar.d.ts +18 -5
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +282 -319
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/current-time.js +26 -25
- package/dist/elements/current-time.js.map +1 -1
- package/dist/elements/drm-badge.d.ts.map +1 -1
- package/dist/elements/drm-badge.js +107 -141
- package/dist/elements/drm-badge.js.map +1 -1
- package/dist/elements/duration.d.ts.map +1 -1
- package/dist/elements/duration.js +24 -21
- package/dist/elements/duration.js.map +1 -1
- package/dist/elements/error-screen.d.ts.map +1 -1
- package/dist/elements/error-screen.js +68 -102
- package/dist/elements/error-screen.js.map +1 -1
- package/dist/elements/fullscreen-button.js +48 -54
- package/dist/elements/fullscreen-button.js.map +1 -1
- package/dist/elements/live-button.d.ts.map +1 -1
- package/dist/elements/live-button.js +67 -94
- package/dist/elements/live-button.js.map +1 -1
- package/dist/elements/menu-element.js +31 -28
- package/dist/elements/menu-element.js.map +1 -1
- package/dist/elements/mute-button.js +58 -59
- package/dist/elements/mute-button.js.map +1 -1
- package/dist/elements/pip-button.js +54 -54
- package/dist/elements/pip-button.js.map +1 -1
- package/dist/elements/play-button.d.ts.map +1 -1
- package/dist/elements/play-button.js +73 -58
- package/dist/elements/play-button.js.map +1 -1
- package/dist/elements/quality-menu.js +66 -69
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/remaining-time.d.ts.map +1 -1
- package/dist/elements/remaining-time.js +27 -24
- package/dist/elements/remaining-time.js.map +1 -1
- package/dist/elements/scan-button.d.ts +17 -0
- package/dist/elements/scan-button.d.ts.map +1 -0
- package/dist/elements/scan-button.js +117 -0
- package/dist/elements/scan-button.js.map +1 -0
- package/dist/elements/seek-bar.d.ts +93 -14
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +475 -335
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/elements/shared.d.ts +3 -11
- package/dist/elements/shared.d.ts.map +1 -1
- package/dist/elements/shared.js +44 -144
- package/dist/elements/shared.js.map +1 -1
- package/dist/elements/skip-button.d.ts.map +1 -1
- package/dist/elements/skip-button.js +54 -55
- package/dist/elements/skip-button.js.map +1 -1
- package/dist/elements/spacer.d.ts.map +1 -1
- package/dist/elements/spacer.js +12 -7
- package/dist/elements/spacer.js.map +1 -1
- package/dist/elements/speed-menu.js +60 -55
- package/dist/elements/speed-menu.js.map +1 -1
- package/dist/elements/spinner.d.ts.map +1 -1
- package/dist/elements/spinner.js +52 -78
- package/dist/elements/spinner.js.map +1 -1
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +107 -120
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.js +95 -103
- package/dist/elements/subtitles-menu.js.map +1 -1
- package/dist/elements/time-element.d.ts.map +1 -1
- package/dist/elements/time-element.js +36 -28
- package/dist/elements/time-element.js.map +1 -1
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +105 -137
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/volume-slider.d.ts.map +1 -1
- package/dist/elements/volume-slider.js +47 -45
- package/dist/elements/volume-slider.js.map +1 -1
- package/dist/elements/volume.d.ts.map +1 -1
- package/dist/elements/volume.js +42 -50
- package/dist/elements/volume.js.map +1 -1
- package/dist/entries/airplay-button.js +7 -7
- package/dist/entries/airplay-button.js.map +1 -1
- package/dist/entries/audio-menu.js +7 -6
- package/dist/entries/audio-menu.js.map +1 -1
- package/dist/entries/chapters-menu.js +7 -7
- package/dist/entries/chapters-menu.js.map +1 -1
- package/dist/entries/control-bar.js +7 -6
- package/dist/entries/control-bar.js.map +1 -1
- package/dist/entries/current-time.js +7 -6
- package/dist/entries/current-time.js.map +1 -1
- package/dist/entries/drm-badge.js +7 -6
- package/dist/entries/drm-badge.js.map +1 -1
- package/dist/entries/duration.js +7 -6
- package/dist/entries/duration.js.map +1 -1
- package/dist/entries/error-screen.js +7 -6
- package/dist/entries/error-screen.js.map +1 -1
- package/dist/entries/fullscreen-button.js +7 -6
- package/dist/entries/fullscreen-button.js.map +1 -1
- package/dist/entries/live-button.js +7 -6
- package/dist/entries/live-button.js.map +1 -1
- package/dist/entries/mute-button.js +7 -6
- package/dist/entries/mute-button.js.map +1 -1
- package/dist/entries/pip-button.js +7 -6
- package/dist/entries/pip-button.js.map +1 -1
- package/dist/entries/play-button.js +7 -6
- package/dist/entries/play-button.js.map +1 -1
- package/dist/entries/quality-menu.js +7 -6
- package/dist/entries/quality-menu.js.map +1 -1
- package/dist/entries/remaining-time.js +7 -7
- package/dist/entries/remaining-time.js.map +1 -1
- package/dist/entries/scan-button.d.ts +5 -0
- package/dist/entries/scan-button.d.ts.map +1 -0
- package/dist/entries/scan-button.js +9 -0
- package/dist/entries/scan-button.js.map +1 -0
- package/dist/entries/seek-bar.js +7 -6
- package/dist/entries/seek-bar.js.map +1 -1
- package/dist/entries/skip-button.js +7 -6
- package/dist/entries/skip-button.js.map +1 -1
- package/dist/entries/spacer.js +7 -6
- package/dist/entries/spacer.js.map +1 -1
- package/dist/entries/speed-menu.js +7 -6
- package/dist/entries/speed-menu.js.map +1 -1
- package/dist/entries/spinner.js +7 -7
- package/dist/entries/spinner.js.map +1 -1
- package/dist/entries/start-button.js +7 -6
- package/dist/entries/start-button.js.map +1 -1
- package/dist/entries/subtitles-menu.js +7 -6
- package/dist/entries/subtitles-menu.js.map +1 -1
- package/dist/entries/title.js +7 -7
- package/dist/entries/title.js.map +1 -1
- package/dist/entries/volume-slider.js +7 -6
- package/dist/entries/volume-slider.js.map +1 -1
- package/dist/entries/volume.js +9 -8
- package/dist/entries/volume.js.map +1 -1
- package/dist/es2015/controls/chapters.js +40 -7
- package/dist/es2015/controls/cues.js +1 -8
- package/dist/es2015/controls/icons.js +3 -1
- package/dist/es2015/controls/menu.js +27 -8
- package/dist/es2015/controls/session.js +16 -4
- package/dist/es2015/controls/slider.js +5 -4
- package/dist/es2015/dom.js +10 -1
- package/dist/es2015/element.js +23 -7
- package/dist/es2015/elements/chapters-menu.js +18 -10
- package/dist/es2015/elements/control-bar.js +41 -35
- package/dist/es2015/elements/drm-badge.js +1 -25
- package/dist/es2015/elements/duration.js +2 -1
- package/dist/es2015/elements/error-screen.js +1 -30
- package/dist/es2015/elements/live-button.js +1 -29
- package/dist/es2015/elements/menu-element.js +2 -2
- package/dist/es2015/elements/play-button.js +10 -3
- package/dist/es2015/elements/remaining-time.js +2 -1
- package/dist/es2015/elements/scan-button.js +118 -0
- package/dist/es2015/elements/seek-bar.js +264 -71
- package/dist/es2015/elements/shared.js +5 -106
- package/dist/es2015/elements/skip-button.js +2 -1
- package/dist/es2015/elements/spacer.js +2 -1
- package/dist/es2015/elements/spinner.js +1 -32
- package/dist/es2015/elements/start-button.js +8 -26
- package/dist/es2015/elements/time-element.js +1 -4
- package/dist/es2015/elements/title.js +1 -45
- package/dist/es2015/elements/volume-slider.js +2 -1
- package/dist/es2015/elements/volume.js +1 -11
- package/dist/es2015/entries/scan-button.js +7 -0
- package/dist/es2015/index.js +3 -1
- package/dist/es2015/style.js +1 -101
- package/dist/es2015/tags.js +2 -1
- package/dist/host.js +19 -17
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -27
- package/dist/labels.js +13 -9
- package/dist/labels.js.map +1 -1
- package/dist/namespaces.d.ts +9 -26
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +6 -2
- package/dist/namespaces.js.map +1 -1
- package/dist/presets.js +33 -28
- package/dist/presets.js.map +1 -1
- package/dist/style.d.ts +1 -20
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +4 -100
- package/dist/style.js.map +1 -1
- package/dist/surface.js +25 -21
- package/dist/surface.js.map +1 -1
- package/dist/tags.d.ts +1 -0
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +31 -26
- package/dist/tags.js.map +1 -1
- package/package.json +4 -4
- package/dist/index.js.map +0 -1
package/dist/controls/pip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip.js","
|
|
1
|
+
{"version":3,"file":"pip.js","names":[],"sources":["../../src/controls/pip.ts"],"sourcesContent":["/**\n * Picture-in-Picture on the video, through whichever API the browser has:\n * the standard one, or Safari's presentation mode. Neither means no\n * button. Both live on the video itself, which is where the browser draws\n * the floating window from.\n */\n\ninterface PresentationVideo {\n webkitSupportsPresentationMode?: (mode: string) => boolean;\n webkitSetPresentationMode?: (mode: string) => void;\n readonly webkitPresentationMode?: string;\n}\n\nexport interface PictureInPicture {\n /** Whether any API exists. Without one the button is hidden. */\n readonly supported: boolean;\n active(): boolean;\n toggle(): void;\n /** Runs `fn` on every change. Returns the unsubscribe. */\n watch(fn: () => void): () => void;\n}\n\nfunction watching(target: EventTarget, names: readonly string[]) {\n return (fn: () => void): (() => void) => {\n for (const name of names) target.addEventListener(name, fn);\n return () => {\n for (const name of names) target.removeEventListener(name, fn);\n };\n };\n}\n\nexport function pictureInPicture(video: HTMLVideoElement): PictureInPicture {\n const safari = video as HTMLVideoElement & PresentationVideo;\n\n if (typeof video.requestPictureInPicture === 'function' && document.pictureInPictureEnabled) {\n return {\n supported: true,\n active: () => document.pictureInPictureElement === video,\n toggle(): void {\n // Rejected outside a user gesture, or before the video has metadata;\n // nothing to do with that but drop it.\n const request =\n document.pictureInPictureElement === video\n ? document.exitPictureInPicture()\n : video.requestPictureInPicture();\n request.catch(() => undefined);\n },\n watch: watching(video, ['enterpictureinpicture', 'leavepictureinpicture']),\n };\n }\n\n if (\n typeof safari.webkitSetPresentationMode === 'function' &&\n safari.webkitSupportsPresentationMode?.('picture-in-picture') === true\n ) {\n return {\n supported: true,\n active: () => safari.webkitPresentationMode === 'picture-in-picture',\n toggle(): void {\n const next =\n safari.webkitPresentationMode === 'picture-in-picture' ? 'inline' : 'picture-in-picture';\n safari.webkitSetPresentationMode?.(next);\n },\n watch: watching(video, ['webkitpresentationmodechanged']),\n };\n }\n\n return {\n supported: false,\n active: () => false,\n toggle(): void {},\n watch: () => () => {},\n };\n}\n"],"mappings":";AAsBA,SAAS,SAAS,QAAqB,OAA0B;CAC/D,QAAQ,OAAiC;EACvC,KAAK,MAAM,QAAQ,OAAO,OAAO,iBAAiB,MAAM,EAAE;EAC1D,aAAa;GACX,KAAK,MAAM,QAAQ,OAAO,OAAO,oBAAoB,MAAM,EAAE;EAC/D;CACF;AACF;AAEA,SAAgB,iBAAiB,OAA2C;CAC1E,MAAM,SAAS;CAEf,IAAI,OAAO,MAAM,4BAA4B,cAAc,SAAS,yBAClE,OAAO;EACL,WAAW;EACX,cAAc,SAAS,4BAA4B;EACnD,SAAe;GAOb,CAHE,SAAS,4BAA4B,QACjC,SAAS,qBAAqB,IAC9B,MAAM,wBAAwB,EAAA,CAC5B,YAAY,KAAA,CAAS;EAC/B;EACA,OAAO,SAAS,OAAO,CAAC,yBAAyB,uBAAuB,CAAC;CAC3E;CAGF,IACE,OAAO,OAAO,8BAA8B,cAC5C,OAAO,iCAAiC,oBAAoB,MAAM,MAElE,OAAO;EACL,WAAW;EACX,cAAc,OAAO,2BAA2B;EAChD,SAAe;GACb,MAAM,OACJ,OAAO,2BAA2B,uBAAuB,WAAW;GACtE,OAAO,4BAA4B,IAAI;EACzC;EACA,OAAO,SAAS,OAAO,CAAC,+BAA+B,CAAC;CAC1D;CAGF,OAAO;EACL,WAAW;EACX,cAAc;EACd,SAAe,CAAC;EAChB,mBAAmB,CAAC;CACtB;AACF"}
|
package/dist/controls/ranges.js
CHANGED
|
@@ -1,48 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//#region src/controls/ranges.ts
|
|
2
|
+
const EMPTY = {
|
|
3
|
+
start: 0,
|
|
4
|
+
end: 0
|
|
5
|
+
};
|
|
6
6
|
/** A `TimeRanges` as spans. */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function spans(ranges) {
|
|
8
|
+
const out = [];
|
|
9
|
+
for (let i = 0; i < ranges.length; i += 1) out.push({
|
|
10
|
+
start: ranges.start(i),
|
|
11
|
+
end: ranges.end(i)
|
|
12
|
+
});
|
|
13
|
+
return out;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
* The span the bar maps: the last seekable range for live, which is the
|
|
17
|
+
* availability window the engine sets on the MediaSource; zero to the
|
|
18
|
+
* duration for VOD; empty while neither is known.
|
|
19
|
+
*/
|
|
20
|
+
function window(duration, seekable, live) {
|
|
21
|
+
if (live) {
|
|
22
|
+
const last = seekable[seekable.length - 1];
|
|
23
|
+
if (last !== void 0 && last.end > last.start) return last;
|
|
24
|
+
}
|
|
25
|
+
return Number.isFinite(duration) && duration > 0 ? {
|
|
26
|
+
start: 0,
|
|
27
|
+
end: duration
|
|
28
|
+
} : EMPTY;
|
|
25
29
|
}
|
|
26
30
|
/** Where a time sits on a span, clamped to it. Zero on an empty span. */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return Math.min(1, Math.max(0, (time - span.start) / length));
|
|
31
|
+
function fraction(time, span) {
|
|
32
|
+
const length = span.end - span.start;
|
|
33
|
+
if (length <= 0) return 0;
|
|
34
|
+
return Math.min(1, Math.max(0, (time - span.start) / length));
|
|
32
35
|
}
|
|
33
36
|
/** The time at a fraction of a span. */
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
function at(part, span) {
|
|
38
|
+
return span.start + Math.min(1, Math.max(0, part)) * (span.end - span.start);
|
|
36
39
|
}
|
|
37
40
|
/** Ranges clipped to a span, as fraction pairs, dropping what falls outside or collapses. */
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return out;
|
|
41
|
+
function clip(ranges, span) {
|
|
42
|
+
const out = [];
|
|
43
|
+
for (const range of ranges) {
|
|
44
|
+
const start = fraction(range.start, span);
|
|
45
|
+
const end = fraction(range.end, span);
|
|
46
|
+
if (end > start) out.push([start, end]);
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
47
49
|
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { EMPTY, at, clip, fraction, spans, window };
|
|
52
|
+
|
|
48
53
|
//# sourceMappingURL=ranges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ranges.js","
|
|
1
|
+
{"version":3,"file":"ranges.js","names":[],"sources":["../../src/controls/ranges.ts"],"sourcesContent":["/**\n * The seek bar's arithmetic, pure and node-tested: which span of time the\n * bar maps, and where a time or a range lands on it as a fraction.\n */\n\nexport interface Span {\n readonly start: number;\n readonly end: number;\n}\n\nexport const EMPTY: Span = { start: 0, end: 0 };\n\n/** A `TimeRanges` as spans. */\nexport function spans(ranges: TimeRanges): Span[] {\n const out: Span[] = [];\n for (let i = 0; i < ranges.length; i += 1)\n out.push({ start: ranges.start(i), end: ranges.end(i) });\n return out;\n}\n\n/**\n * The span the bar maps: the last seekable range for live, which is the\n * availability window the engine sets on the MediaSource; zero to the\n * duration for VOD; empty while neither is known.\n */\nexport function window(duration: number, seekable: readonly Span[], live: boolean): Span {\n if (live) {\n const last = seekable[seekable.length - 1];\n if (last !== undefined && last.end > last.start) return last;\n }\n return Number.isFinite(duration) && duration > 0 ? { start: 0, end: duration } : EMPTY;\n}\n\n/** Where a time sits on a span, clamped to it. Zero on an empty span. */\nexport function fraction(time: number, span: Span): number {\n const length = span.end - span.start;\n if (length <= 0) return 0;\n return Math.min(1, Math.max(0, (time - span.start) / length));\n}\n\n/** The time at a fraction of a span. */\nexport function at(part: number, span: Span): number {\n return span.start + Math.min(1, Math.max(0, part)) * (span.end - span.start);\n}\n\n/** Ranges clipped to a span, as fraction pairs, dropping what falls outside or collapses. */\nexport function clip(ranges: readonly Span[], span: Span): Array<readonly [number, number]> {\n const out: Array<readonly [number, number]> = [];\n for (const range of ranges) {\n const start = fraction(range.start, span);\n const end = fraction(range.end, span);\n if (end > start) out.push([start, end]);\n }\n return out;\n}\n"],"mappings":";AAUA,MAAa,QAAc;CAAE,OAAO;CAAG,KAAK;AAAE;;AAG9C,SAAgB,MAAM,QAA4B;CAChD,MAAM,MAAc,CAAC;CACrB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GACtC,IAAI,KAAK;EAAE,OAAO,OAAO,MAAM,CAAC;EAAG,KAAK,OAAO,IAAI,CAAC;CAAE,CAAC;CACzD,OAAO;AACT;;;;;;AAOA,SAAgB,OAAO,UAAkB,UAA2B,MAAqB;CACvF,IAAI,MAAM;EACR,MAAM,OAAO,SAAS,SAAS,SAAS;EACxC,IAAI,SAAS,KAAA,KAAa,KAAK,MAAM,KAAK,OAAO,OAAO;CAC1D;CACA,OAAO,OAAO,SAAS,QAAQ,KAAK,WAAW,IAAI;EAAE,OAAO;EAAG,KAAK;CAAS,IAAI;AACnF;;AAGA,SAAgB,SAAS,MAAc,MAAoB;CACzD,MAAM,SAAS,KAAK,MAAM,KAAK;CAC/B,IAAI,UAAU,GAAG,OAAO;CACxB,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,MAAM,CAAC;AAC9D;;AAGA,SAAgB,GAAG,MAAc,MAAoB;CACnD,OAAO,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC,KAAK,KAAK,MAAM,KAAK;AACxE;;AAGA,SAAgB,KAAK,QAAyB,MAA8C;CAC1F,MAAM,MAAwC,CAAC;CAC/C,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAAQ,SAAS,MAAM,OAAO,IAAI;EACxC,MAAM,MAAM,SAAS,MAAM,KAAK,IAAI;EACpC,IAAI,MAAM,OAAO,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC;CACxC;CACA,OAAO;AACT"}
|
|
@@ -20,7 +20,12 @@ export declare function live(engine: Mattebox | null): LiveApi | undefined;
|
|
|
20
20
|
* to the duration for VOD.
|
|
21
21
|
*/
|
|
22
22
|
export declare function span(video: HTMLVideoElement, engine: Mattebox | null): Span;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The engine's forward buffer goal in seconds, which lives on the
|
|
25
|
+
* diagnostics snapshot and nowhere else. A scan multiplies the goal by its
|
|
26
|
+
* rate and a scrub shrinks it (engine guide, trick play), so meanwhile the
|
|
27
|
+
* goal from before stands: a live bar must not hide in the middle of a scan.
|
|
28
|
+
*/
|
|
24
29
|
export declare function bufferGoal(engine: Mattebox | null): number | null;
|
|
25
30
|
/** The wall clock at a presentation time, when the session can say it. */
|
|
26
31
|
export declare function wall(engine: Mattebox | null, time: number): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/controls/session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAIxC,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,CAE5D;AAED,kGAAkG;AAClG,wBAAgB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,CAGjE;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAK3E;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/controls/session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAIxC,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,CAE5D;AAED,kGAAkG;AAClG,wBAAgB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,CAGjE;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAK3E;AAKD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAQjE;AAED,0EAA0E;AAC1E,wBAAgB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGzE"}
|
package/dist/controls/session.js
CHANGED
|
@@ -1,36 +1,51 @@
|
|
|
1
|
-
import { namespaces } from
|
|
2
|
-
import { spans, window } from
|
|
3
|
-
import { clock } from
|
|
1
|
+
import { namespaces } from "../namespaces.js";
|
|
2
|
+
import { spans, window } from "./ranges.js";
|
|
3
|
+
import { clock } from "./time.js";
|
|
4
|
+
//#region src/controls/session.ts
|
|
4
5
|
/** The optional namespaces of an engine, or none for a native session. */
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
function optional(engine) {
|
|
7
|
+
return engine === null ? {} : namespaces(engine);
|
|
7
8
|
}
|
|
8
9
|
/** The live namespace once the stream has an availability window, which is what makes it live. */
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
function live(engine) {
|
|
11
|
+
const api = optional(engine).live;
|
|
12
|
+
return api !== void 0 && api.edge !== null ? api : void 0;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return window(video.duration, spans(video.seekable), on);
|
|
15
|
+
* The span the bar maps: the engine's own availability window for live,
|
|
16
|
+
* where the session offers it, because the browser's seekable range on a
|
|
17
|
+
* live MediaSource is the union of that window and whatever is buffered
|
|
18
|
+
* and grows behind a paused playhead; the seekable range otherwise; zero
|
|
19
|
+
* to the duration for VOD.
|
|
20
|
+
*/
|
|
21
|
+
function span(video, engine) {
|
|
22
|
+
const on = live(engine) !== void 0;
|
|
23
|
+
const own = on ? engine?.stats.snapshot().live?.span ?? null : null;
|
|
24
|
+
if (own !== null && own.end > own.start) return own;
|
|
25
|
+
return window(video.duration, spans(video.seekable), on);
|
|
26
26
|
}
|
|
27
|
-
/** The
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/** The goal each engine had outside a scan or a scrub. */
|
|
28
|
+
const settled = /* @__PURE__ */ new WeakMap();
|
|
29
|
+
/**
|
|
30
|
+
* The engine's forward buffer goal in seconds, which lives on the
|
|
31
|
+
* diagnostics snapshot and nowhere else. A scan multiplies the goal by its
|
|
32
|
+
* rate and a scrub shrinks it (engine guide, trick play), so meanwhile the
|
|
33
|
+
* goal from before stands: a live bar must not hide in the middle of a scan.
|
|
34
|
+
*/
|
|
35
|
+
function bufferGoal(engine) {
|
|
36
|
+
if (engine === null) return null;
|
|
37
|
+
const trick = optional(engine).trick;
|
|
38
|
+
if (trick !== void 0 && (trick.rate !== 1 || trick.scrubbing)) return settled.get(engine) ?? null;
|
|
39
|
+
const goal = engine.stats.snapshot().scheduling.bufferGoal;
|
|
40
|
+
settled.set(engine, goal);
|
|
41
|
+
return goal;
|
|
30
42
|
}
|
|
31
43
|
/** The wall clock at a presentation time, when the session can say it. */
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
function wall(engine, time) {
|
|
45
|
+
const epoch = optional(engine).pdt?.toWallClock(time) ?? null;
|
|
46
|
+
return epoch === null ? null : clock(epoch);
|
|
35
47
|
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { bufferGoal, live, optional, span, wall };
|
|
50
|
+
|
|
36
51
|
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","
|
|
1
|
+
{"version":3,"file":"session.js","names":[],"sources":["../../src/controls/session.ts"],"sourcesContent":["/**\n * What the seek row reads of a session, in one place, so the time, the\n * seek bar and the live button agree: whether the stream is live, the span\n * the bar maps, and the wall clock at a presentation time. Every read is\n * feature-tested through `namespaces()`, and a native session answers as\n * VOD with no window and no clock.\n */\nimport type { Mattebox } from 'mattebox';\nimport type { LiveApi, Namespaces } from '../namespaces.js';\nimport { namespaces } from '../namespaces.js';\nimport type { Span } from './ranges.js';\nimport { spans, window } from './ranges.js';\nimport { clock } from './time.js';\n\n/** The optional namespaces of an engine, or none for a native session. */\nexport function optional(engine: Mattebox | null): Namespaces {\n return engine === null ? {} : namespaces(engine);\n}\n\n/** The live namespace once the stream has an availability window, which is what makes it live. */\nexport function live(engine: Mattebox | null): LiveApi | undefined {\n const api = optional(engine).live;\n return api !== undefined && api.edge !== null ? api : undefined;\n}\n\n/**\n * The span the bar maps: the engine's own availability window for live,\n * where the session offers it, because the browser's seekable range on a\n * live MediaSource is the union of that window and whatever is buffered\n * and grows behind a paused playhead; the seekable range otherwise; zero\n * to the duration for VOD.\n */\nexport function span(video: HTMLVideoElement, engine: Mattebox | null): Span {\n const on = live(engine) !== undefined;\n const own = on ? (engine?.stats.snapshot().live?.span ?? null) : null;\n if (own !== null && own.end > own.start) return own;\n return window(video.duration, spans(video.seekable), on);\n}\n\n/** The goal each engine had outside a scan or a scrub. */\nconst settled = new WeakMap<Mattebox, number>();\n\n/**\n * The engine's forward buffer goal in seconds, which lives on the\n * diagnostics snapshot and nowhere else. A scan multiplies the goal by its\n * rate and a scrub shrinks it (engine guide, trick play), so meanwhile the\n * goal from before stands: a live bar must not hide in the middle of a scan.\n */\nexport function bufferGoal(engine: Mattebox | null): number | null {\n if (engine === null) return null;\n const trick = optional(engine).trick;\n const held = trick !== undefined && (trick.rate !== 1 || trick.scrubbing);\n if (held) return settled.get(engine) ?? null;\n const goal = engine.stats.snapshot().scheduling.bufferGoal;\n settled.set(engine, goal);\n return goal;\n}\n\n/** The wall clock at a presentation time, when the session can say it. */\nexport function wall(engine: Mattebox | null, time: number): string | null {\n const epoch = optional(engine).pdt?.toWallClock(time) ?? null;\n return epoch === null ? null : clock(epoch);\n}\n"],"mappings":";;;;;AAeA,SAAgB,SAAS,QAAqC;CAC5D,OAAO,WAAW,OAAO,CAAC,IAAI,WAAW,MAAM;AACjD;;AAGA,SAAgB,KAAK,QAA8C;CACjE,MAAM,MAAM,SAAS,MAAM,CAAC,CAAC;CAC7B,OAAO,QAAQ,KAAA,KAAa,IAAI,SAAS,OAAO,MAAM,KAAA;AACxD;;;;;;;;AASA,SAAgB,KAAK,OAAyB,QAA+B;CAC3E,MAAM,KAAK,KAAK,MAAM,MAAM,KAAA;CAC5B,MAAM,MAAM,KAAM,QAAQ,MAAM,SAAS,CAAC,CAAC,MAAM,QAAQ,OAAQ;CACjE,IAAI,QAAQ,QAAQ,IAAI,MAAM,IAAI,OAAO,OAAO;CAChD,OAAO,OAAO,MAAM,UAAU,MAAM,MAAM,QAAQ,GAAG,EAAE;AACzD;;AAGA,MAAM,0BAAU,IAAI,QAA0B;;;;;;;AAQ9C,SAAgB,WAAW,QAAwC;CACjE,IAAI,WAAW,MAAM,OAAO;CAC5B,MAAM,QAAQ,SAAS,MAAM,CAAC,CAAC;CAE/B,IADa,UAAU,KAAA,MAAc,MAAM,SAAS,KAAK,MAAM,YACrD,OAAO,QAAQ,IAAI,MAAM,KAAK;CACxC,MAAM,OAAO,OAAO,MAAM,SAAS,CAAC,CAAC,WAAW;CAChD,QAAQ,IAAI,QAAQ,IAAI;CACxB,OAAO;AACT;;AAGA,SAAgB,KAAK,QAAyB,MAA6B;CACzE,MAAM,QAAQ,SAAS,MAAM,CAAC,CAAC,KAAK,YAAY,IAAI,KAAK;CACzD,OAAO,UAAU,OAAO,OAAO,MAAM,KAAK;AAC5C"}
|
|
@@ -3,8 +3,8 @@ export interface SliderOptions {
|
|
|
3
3
|
readonly step: () => number;
|
|
4
4
|
/** What Page Up and Page Down move it by. */
|
|
5
5
|
readonly page: () => number;
|
|
6
|
-
/** The value the pointer or a key asked for, clamped to the range. */
|
|
7
|
-
readonly onInput: (value: number) => void;
|
|
6
|
+
/** The value the pointer or a key asked for, clamped to the range, and whether a key asked. */
|
|
7
|
+
readonly onInput: (value: number, key: boolean) => void;
|
|
8
8
|
/** A pointer took the thumb, or let it go. The element carries it as `dragging`. */
|
|
9
9
|
readonly onDrag: (on: boolean) => void;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../src/controls/slider.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC;IAC5B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC;IAC5B
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../src/controls/slider.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC;IAC5B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC;IAC5B,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,2BAA2B;IAC3B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,+FAA+F;IAC/F,QAAQ,IAAI,OAAO,CAAC;IACpB,qCAAqC;IACrC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,4DAA4D;IAC5D,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,OAAO,IAAI,IAAI,CAAC;CACjB;AAMD,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA+IrD"}
|
package/dist/controls/slider.js
CHANGED
|
@@ -1,164 +1,156 @@
|
|
|
1
|
+
import { el } from "../dom.js";
|
|
2
|
+
//#region src/controls/slider.ts
|
|
1
3
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import { el } from '../dom.js';
|
|
4
|
+
* The slider primitive the seek bar and the volume share: a `div` with
|
|
5
|
+
* `role="slider"`, pointer capture for the drag, and the arrow keys. It
|
|
6
|
+
* owns geometry only. What the value means and what happens on change is
|
|
7
|
+
* the caller's, through `onInput`.
|
|
8
|
+
*
|
|
9
|
+
* Not `<input type="range">`: a range input cannot carry layers such as
|
|
10
|
+
* buffered ranges, its geometry is not readable for a preview anchor, and
|
|
11
|
+
* it renders differently per browser. The track is exposed so a caller can
|
|
12
|
+
* lay its own layers on it.
|
|
13
|
+
*
|
|
14
|
+
* The track and the thumb sit on a rail inset from the root's edges by half
|
|
15
|
+
* a thumb, so the thumb at either end is whole and not clipped, and every
|
|
16
|
+
* fraction is measured against the rail.
|
|
17
|
+
*
|
|
18
|
+
* The steps are read on every key, so an element can take them from its
|
|
19
|
+
* attributes as they change.
|
|
20
|
+
*
|
|
21
|
+
* A drag ends on `pointerup`, and also on a move that reports no button
|
|
22
|
+
* held: the button went up where no `pointerup` reached the slider, such
|
|
23
|
+
* as outside the window, and the thumb must not stay on the pointer. A
|
|
24
|
+
* lost capture ends it too.
|
|
25
|
+
*/
|
|
25
26
|
function clamp(value, min, max) {
|
|
26
|
-
|
|
27
|
+
return Math.min(max, Math.max(min, value));
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
root.setAttribute('aria-valuetext', text);
|
|
152
|
-
paint();
|
|
153
|
-
},
|
|
154
|
-
dispose() {
|
|
155
|
-
root.removeEventListener('pointerdown', down);
|
|
156
|
-
root.removeEventListener('pointermove', move);
|
|
157
|
-
root.removeEventListener('pointerup', up);
|
|
158
|
-
root.removeEventListener('pointercancel', cancel);
|
|
159
|
-
root.removeEventListener('lostpointercapture', cancel);
|
|
160
|
-
root.removeEventListener('keydown', key);
|
|
161
|
-
},
|
|
162
|
-
};
|
|
29
|
+
function slider(options) {
|
|
30
|
+
const { onInput } = options;
|
|
31
|
+
const root = el("div", "slider");
|
|
32
|
+
root.setAttribute("role", "slider");
|
|
33
|
+
root.tabIndex = 0;
|
|
34
|
+
const rail = el("div", "rail");
|
|
35
|
+
const track = el("div", "track");
|
|
36
|
+
const fill = el("div", "fill");
|
|
37
|
+
const thumb = el("div", "thumb");
|
|
38
|
+
track.append(fill);
|
|
39
|
+
rail.append(track, thumb);
|
|
40
|
+
root.append(rail);
|
|
41
|
+
let min = 0;
|
|
42
|
+
let max = 1;
|
|
43
|
+
let value = 0;
|
|
44
|
+
let held = false;
|
|
45
|
+
function paint() {
|
|
46
|
+
const percent = `${(max > min ? (value - min) / (max - min) : 0) * 100}%`;
|
|
47
|
+
fill.style.width = percent;
|
|
48
|
+
thumb.style.left = percent;
|
|
49
|
+
}
|
|
50
|
+
/** The value under a horizontal pointer position. */
|
|
51
|
+
function at(clientX) {
|
|
52
|
+
const rect = rail.getBoundingClientRect();
|
|
53
|
+
if (rect.width === 0) return min;
|
|
54
|
+
return min + clamp((clientX - rect.left) / rect.width, 0, 1) * (max - min);
|
|
55
|
+
}
|
|
56
|
+
function hold(on) {
|
|
57
|
+
held = on;
|
|
58
|
+
options.onDrag(on);
|
|
59
|
+
}
|
|
60
|
+
function down(event) {
|
|
61
|
+
if (event.button !== 0) return;
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
hold(true);
|
|
64
|
+
try {
|
|
65
|
+
root.setPointerCapture(event.pointerId);
|
|
66
|
+
} catch {}
|
|
67
|
+
onInput(at(event.clientX), false);
|
|
68
|
+
}
|
|
69
|
+
function move(event) {
|
|
70
|
+
if (!held) return;
|
|
71
|
+
if (event.buttons === 0) {
|
|
72
|
+
up(event);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
onInput(at(event.clientX), false);
|
|
76
|
+
}
|
|
77
|
+
function up(event) {
|
|
78
|
+
if (!held) return;
|
|
79
|
+
hold(false);
|
|
80
|
+
onInput(at(event.clientX), false);
|
|
81
|
+
}
|
|
82
|
+
function cancel() {
|
|
83
|
+
if (held) hold(false);
|
|
84
|
+
}
|
|
85
|
+
function key(event) {
|
|
86
|
+
if (event.defaultPrevented) return;
|
|
87
|
+
let next;
|
|
88
|
+
switch (event.key) {
|
|
89
|
+
case "ArrowRight":
|
|
90
|
+
case "ArrowUp":
|
|
91
|
+
next = value + options.step();
|
|
92
|
+
break;
|
|
93
|
+
case "ArrowLeft":
|
|
94
|
+
case "ArrowDown":
|
|
95
|
+
next = value - options.step();
|
|
96
|
+
break;
|
|
97
|
+
case "PageUp":
|
|
98
|
+
next = value + options.page();
|
|
99
|
+
break;
|
|
100
|
+
case "PageDown":
|
|
101
|
+
next = value - options.page();
|
|
102
|
+
break;
|
|
103
|
+
case "Home":
|
|
104
|
+
next = min;
|
|
105
|
+
break;
|
|
106
|
+
case "End":
|
|
107
|
+
next = max;
|
|
108
|
+
break;
|
|
109
|
+
default: return;
|
|
110
|
+
}
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
onInput(clamp(next, min, max), true);
|
|
113
|
+
}
|
|
114
|
+
root.addEventListener("pointerdown", down);
|
|
115
|
+
root.addEventListener("pointermove", move);
|
|
116
|
+
root.addEventListener("pointerup", up);
|
|
117
|
+
root.addEventListener("pointercancel", cancel);
|
|
118
|
+
root.addEventListener("lostpointercapture", cancel);
|
|
119
|
+
root.addEventListener("keydown", key);
|
|
120
|
+
return {
|
|
121
|
+
root,
|
|
122
|
+
track,
|
|
123
|
+
rail,
|
|
124
|
+
label(text) {
|
|
125
|
+
root.setAttribute("aria-label", text);
|
|
126
|
+
},
|
|
127
|
+
dragging() {
|
|
128
|
+
return held;
|
|
129
|
+
},
|
|
130
|
+
range(low, high) {
|
|
131
|
+
min = low;
|
|
132
|
+
max = high;
|
|
133
|
+
root.setAttribute("aria-valuemin", String(low));
|
|
134
|
+
root.setAttribute("aria-valuemax", String(high));
|
|
135
|
+
paint();
|
|
136
|
+
},
|
|
137
|
+
set(next, text) {
|
|
138
|
+
value = clamp(next, min, max);
|
|
139
|
+
root.setAttribute("aria-valuenow", String(value));
|
|
140
|
+
root.setAttribute("aria-valuetext", text);
|
|
141
|
+
paint();
|
|
142
|
+
},
|
|
143
|
+
dispose() {
|
|
144
|
+
root.removeEventListener("pointerdown", down);
|
|
145
|
+
root.removeEventListener("pointermove", move);
|
|
146
|
+
root.removeEventListener("pointerup", up);
|
|
147
|
+
root.removeEventListener("pointercancel", cancel);
|
|
148
|
+
root.removeEventListener("lostpointercapture", cancel);
|
|
149
|
+
root.removeEventListener("keydown", key);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
163
152
|
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { slider };
|
|
155
|
+
|
|
164
156
|
//# sourceMappingURL=slider.js.map
|