polite-media 0.4.3 → 0.5.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/CHANGELOG.md +45 -0
- package/README.md +59 -35
- package/dist/coordinator.d.ts +4 -2
- package/dist/coordinator.d.ts.map +1 -1
- package/dist/coordinator.js +52 -26
- package/dist/coordinator.js.map +1 -1
- package/dist/events.d.ts +8 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +6 -0
- package/dist/events.js.map +1 -1
- package/dist/image.css +1 -1
- package/dist/image.d.ts +6 -13
- package/dist/image.d.ts.map +1 -1
- package/dist/image.js +23 -15
- package/dist/image.js.map +1 -1
- package/dist/layer.css +1 -1
- package/dist/video.css +1 -1
- package/dist/video.d.ts +1 -1
- package/dist/video.d.ts.map +1 -1
- package/dist/video.js +1 -1
- package/dist/video.js.map +1 -1
- package/package.json +1 -1
- package/src/coordinator.ts +74 -42
- package/src/events.ts +9 -0
- package/src/image.css +10 -5
- package/src/image.ts +32 -26
- package/src/layer.css +3 -2
- package/src/video.css +19 -13
- package/src/video.ts +1 -0
package/src/video.css
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* is why it works at any video size, and it would be undone by a single width
|
|
7
7
|
* declaration here.
|
|
8
8
|
*
|
|
9
|
-
* `data-polite-media` goes on the
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* `data-polite-media` goes on the box in your markup, not from script. It has
|
|
10
|
+
* to be authored: a <video preload="none"> paints an empty box, and if the base
|
|
11
|
+
* "hidden" state only arrived once JS ran, a page whose bundle failed would
|
|
12
|
+
* show that empty box stacked over the poster. Authored, the safe state is the
|
|
13
|
+
* default and the library only ever has to reveal.
|
|
14
14
|
*
|
|
15
|
-
* Expected shape -- poster
|
|
15
|
+
* Expected shape -- poster a direct child, video anywhere inside, one box:
|
|
16
16
|
*
|
|
17
17
|
* <div class="whatever-you-like" data-polite-media>
|
|
18
18
|
* <img src="poster.avif" alt="">
|
|
@@ -21,9 +21,15 @@
|
|
|
21
21
|
* </video>
|
|
22
22
|
* </div>
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* The video rules use a descendant combinator so a wrapper between box and
|
|
25
|
+
* video is fine; the poster rule stays a direct child so a logo deeper in the
|
|
26
|
+
* box is left alone. One box holds one video, and boxes must not nest: the
|
|
27
|
+
* ready state reveals every video inside the box.
|
|
28
|
+
*
|
|
29
|
+
* Attributes the library sets on that box:
|
|
30
|
+
* data-polite-ready a frame has actually painted
|
|
31
|
+
* data-polite-failed no source could be decoded; the poster is now permanent
|
|
32
|
+
* data-polite-blocked play() refused until a gesture; the library is retrying
|
|
27
33
|
* And on <html>:
|
|
28
34
|
* data-polite-paused the user stopped playback via a [data-polite-pause-control] control
|
|
29
35
|
*
|
|
@@ -38,12 +44,12 @@
|
|
|
38
44
|
* of an async decode landing. Set the property to override both at once.
|
|
39
45
|
*/
|
|
40
46
|
|
|
41
|
-
[data-polite-media]
|
|
47
|
+
[data-polite-media] video {
|
|
42
48
|
opacity: 0;
|
|
43
49
|
transition: opacity var(--polite-fade, 0s) ease;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
[data-polite-media][data-polite-ready]
|
|
52
|
+
[data-polite-media][data-polite-ready] video {
|
|
47
53
|
opacity: 1;
|
|
48
54
|
}
|
|
49
55
|
|
|
@@ -62,12 +68,12 @@
|
|
|
62
68
|
* half-decoded frame stuck at opacity 1 is exactly the state a viewer would
|
|
63
69
|
* report as broken.
|
|
64
70
|
*/
|
|
65
|
-
[data-polite-media][data-polite-failed]
|
|
71
|
+
[data-polite-media][data-polite-failed] video {
|
|
66
72
|
opacity: 0;
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
@media (prefers-reduced-motion: reduce) {
|
|
70
|
-
[data-polite-media]
|
|
76
|
+
[data-polite-media] video,
|
|
71
77
|
[data-polite-media] > :is(img, picture) {
|
|
72
78
|
transition: none;
|
|
73
79
|
}
|
package/src/video.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type { AtOnce, ConfigureOptions, RegisterOptions, VideoTarget } from './c
|
|
|
24
24
|
// ElementEventMap and DocumentEventMap augmentation only reaches a consumer if
|
|
25
25
|
// this module is part of their program.
|
|
26
26
|
export {
|
|
27
|
+
POLITE_VIDEO_BLOCKED,
|
|
27
28
|
POLITE_VIDEO_PAUSECHANGE,
|
|
28
29
|
POLITE_VIDEO_FAILED,
|
|
29
30
|
POLITE_VIDEO_READY,
|