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/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 container in your markup, not from script.
10
- * It has to be authored: a <video preload="none"> paints an empty box, and if
11
- * the base "hidden" state only arrived once JS ran, a page whose bundle failed
12
- * would show that empty box stacked over the poster. Authored, the safe state is
13
- * the default and the library only ever has to reveal.
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 first, video second, sharing one box:
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
- * Attributes the library sets on that container:
25
- * data-polite-ready a frame has actually painted
26
- * data-polite-failed no source could be decoded; the poster is now permanent
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] > video {
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] > video {
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] > video {
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] > video,
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,