@plusguard/reels 1.8.0 → 1.9.1
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 +11 -8
- package/dist/index.js +30 -2
- package/index.css +19 -4
- package/index.ts +31 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,9 +23,9 @@ From npm, through jsDelivr — the npm package is the code alone (about
|
|
|
23
23
|
jsDelivr's GitHub route.
|
|
24
24
|
|
|
25
25
|
```html
|
|
26
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@plusguard/reels@1.
|
|
26
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@plusguard/reels@1.9.1/index.css" />
|
|
27
27
|
<script type="module">
|
|
28
|
-
import { initReels } from "https://cdn.jsdelivr.net/npm/@plusguard/reels@1.
|
|
28
|
+
import { initReels } from "https://cdn.jsdelivr.net/npm/@plusguard/reels@1.9.1/dist/index.js";
|
|
29
29
|
initReels();
|
|
30
30
|
</script>
|
|
31
31
|
```
|
|
@@ -97,8 +97,8 @@ below).
|
|
|
97
97
|
- **Sound is one card's.** A sound button pressed gives the sound to its
|
|
98
98
|
card — every other card is muted; pressed again, off. The card going out
|
|
99
99
|
of sight takes the sound with it. The full view takes
|
|
100
|
-
it over while open
|
|
101
|
-
|
|
100
|
+
it over while open — from the card it opened on, if that one had it —
|
|
101
|
+
and keeps it: closed, every card is muted again.
|
|
102
102
|
- **The strip scrolls sideways** — a finger, a wheel, its arrows, one card
|
|
103
103
|
a press. It never moves by itself. `data-pg-reels-start` / `-end` on the
|
|
104
104
|
section while it stands at either end, for the arrows.
|
|
@@ -169,7 +169,7 @@ in it, copies of the site's markup: the clip, the group's
|
|
|
169
169
|
as a post opened on Instagram (no corners where they meet, rounded ones
|
|
170
170
|
outside), as tall as the video, about a third of the
|
|
171
171
|
window wide: a head — the template's `data-pg-reels-title`, moved there
|
|
172
|
-
(the example puts the
|
|
172
|
+
(the example puts the product's name there) — a line under it; at the
|
|
173
173
|
bottom a foot — the template's `data-pg-reels-foot`, the link to the
|
|
174
174
|
product, always in sight; and between them the rest of the template,
|
|
175
175
|
scrolling.
|
|
@@ -320,9 +320,12 @@ three to five clips, videos (`?duration=2s` sets a picture's time; the
|
|
|
320
320
|
switches at the top for the rings — pale once seen or always bright, and
|
|
321
321
|
bright again after a minute, an hour, a day or never: `?seen=off`,
|
|
322
322
|
`?seen-for=1h`), each clip with a product and its
|
|
323
|
-
details: its
|
|
324
|
-
|
|
325
|
-
|
|
323
|
+
details: its name heading the panel, a big picture at 16:9, small ones
|
|
324
|
+
— nine for the first product, a row that scrolls — the price, variants
|
|
325
|
+
as pills where there are some, a line about it, the post's text with its
|
|
326
|
+
#tags — links to them where the post is: Instagram, TikTok or YouTube —
|
|
327
|
+
a link. Every link out of the site (the profiles, the tags) is
|
|
328
|
+
`rel="nofollow noopener"`. Under the card the product
|
|
326
329
|
shows "In the video" over its name, the name in two lines' room (longer
|
|
327
330
|
ends in "…"), so every row is as tall — no price: it is one press away,
|
|
328
331
|
in the full view; over each clip's caption its category, a link to it
|
package/dist/index.js
CHANGED
|
@@ -687,9 +687,32 @@ export function initReels() {
|
|
|
687
687
|
const viewVideo = () => media.querySelector("video");
|
|
688
688
|
const current = () => view.list[view.gi];
|
|
689
689
|
let headOf = null;
|
|
690
|
+
// A clip's still: a video's poster, or the picture itself.
|
|
691
|
+
const stillOf = (clip) => clip?.querySelector("video")?.getAttribute("poster") || clip?.querySelector("img")?.getAttribute("src") || "";
|
|
692
|
+
// The stills shown next — the groups beside the one shown, the ones
|
|
693
|
+
// beside those, the clip after this one — fetched and decoded ahead: a
|
|
694
|
+
// group sliding in, the one coming in under it, the next clip, are
|
|
695
|
+
// never blank first.
|
|
696
|
+
const warmed = new Set();
|
|
697
|
+
const warm = (clip) => {
|
|
698
|
+
const src = stillOf(clip);
|
|
699
|
+
if (!src || warmed.has(src))
|
|
700
|
+
return;
|
|
701
|
+
warmed.add(src);
|
|
702
|
+
const img = new Image();
|
|
703
|
+
img.src = src;
|
|
704
|
+
img.decode?.().catch(() => { });
|
|
705
|
+
};
|
|
706
|
+
// Its still behind it too, painted at once from the cache, until the
|
|
707
|
+
// video's own poster and frames are there.
|
|
708
|
+
const backed = (holder, clip) => {
|
|
709
|
+
const src = stillOf(clip);
|
|
710
|
+
holder.style.background = src ? `#000 url(${JSON.stringify(src)}) center / cover no-repeat` : "";
|
|
711
|
+
};
|
|
690
712
|
// A group's first clip, for the video above or under the one shown:
|
|
691
713
|
// a picture, or a video on its poster — never playing.
|
|
692
714
|
const peekOf = (holder, g) => {
|
|
715
|
+
backed(holder, g?.clips[0]);
|
|
693
716
|
holder.replaceChildren(...(g ? [copyOf(g.clips[0])] : []));
|
|
694
717
|
holder.hidden = !g;
|
|
695
718
|
holder.querySelectorAll("video").forEach((x) => {
|
|
@@ -744,9 +767,12 @@ export function initReels() {
|
|
|
744
767
|
v.preload = "auto";
|
|
745
768
|
v.loop = false;
|
|
746
769
|
}
|
|
770
|
+
backed(media, clip);
|
|
747
771
|
media.replaceChildren(copy);
|
|
748
772
|
peekOf(before, view.list[view.gi - 1]);
|
|
749
773
|
peekOf(after, view.list[view.gi + 1]);
|
|
774
|
+
[-2, -1, 1, 2].forEach((d) => warm(view.list[view.gi + d]?.clips[0]));
|
|
775
|
+
warm(g.clips[view.ci + 1]);
|
|
750
776
|
const product = g.products[view.ci];
|
|
751
777
|
part("panel-summary").replaceChildren(...(product ? [copyOf(product)] : []));
|
|
752
778
|
// The details: in the product, or in the clip — a <template>, or
|
|
@@ -962,8 +988,10 @@ export function initReels() {
|
|
|
962
988
|
const g = current();
|
|
963
989
|
if (g)
|
|
964
990
|
show(g, view.ci);
|
|
965
|
-
//
|
|
966
|
-
|
|
991
|
+
// Closed, the cards are all muted again — the full view's sound
|
|
992
|
+
// stays in it, whichever card it came from.
|
|
993
|
+
sound = false;
|
|
994
|
+
owner = null;
|
|
967
995
|
if (dialog.open)
|
|
968
996
|
dialog.close();
|
|
969
997
|
media.replaceChildren();
|
package/index.css
CHANGED
|
@@ -65,7 +65,11 @@
|
|
|
65
65
|
inset: 0;
|
|
66
66
|
margin: 0;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
/* The playing clip shows. Before the script has chosen one — the first
|
|
69
|
+
paint, the page still loading — the first does: the card is never
|
|
70
|
+
blank, and nothing comes and goes as the script starts. */
|
|
71
|
+
[data-pg-reels-card]:has([data-pg-reels-clip][data-pg-reels-current]) [data-pg-reels-clip]:not([data-pg-reels-current]),
|
|
72
|
+
[data-pg-reels-card]:not(:has([data-pg-reels-clip][data-pg-reels-current])) [data-pg-reels-clip] ~ [data-pg-reels-clip] {
|
|
69
73
|
visibility: hidden;
|
|
70
74
|
}
|
|
71
75
|
[data-pg-reels-clip] > video,
|
|
@@ -82,6 +86,9 @@
|
|
|
82
86
|
[data-pg-reels-bars] {
|
|
83
87
|
display: flex;
|
|
84
88
|
gap: 0.25rem;
|
|
89
|
+
/* Its row's room from the first paint, before the script fills it:
|
|
90
|
+
nothing under it moves down when the bars come. */
|
|
91
|
+
min-height: 0.75rem;
|
|
85
92
|
}
|
|
86
93
|
[data-pg-reels-bar],
|
|
87
94
|
[data-pg-reels-view-bar] {
|
|
@@ -136,9 +143,12 @@
|
|
|
136
143
|
display: none !important;
|
|
137
144
|
}
|
|
138
145
|
|
|
139
|
-
/* The products and the view counts: only the playing clip's show
|
|
140
|
-
|
|
141
|
-
[data-pg-reels-group] [data-pg-reels-
|
|
146
|
+
/* The products and the view counts: only the playing clip's show —
|
|
147
|
+
before the script has chosen, the first. */
|
|
148
|
+
[data-pg-reels-group]:has([data-pg-reels-product][data-pg-reels-current]) [data-pg-reels-product]:not([data-pg-reels-current]),
|
|
149
|
+
[data-pg-reels-group]:not(:has([data-pg-reels-product][data-pg-reels-current])) [data-pg-reels-product] ~ [data-pg-reels-product],
|
|
150
|
+
[data-pg-reels-group]:has([data-pg-reels-views][data-pg-reels-current]) [data-pg-reels-views]:not([data-pg-reels-current]),
|
|
151
|
+
[data-pg-reels-group]:not(:has([data-pg-reels-views][data-pg-reels-current])) [data-pg-reels-views] ~ [data-pg-reels-views] {
|
|
142
152
|
display: none !important;
|
|
143
153
|
}
|
|
144
154
|
|
|
@@ -573,6 +583,11 @@ dialog[data-pg-reels-viewer] [data-pg-reels-view-steps] svg {
|
|
|
573
583
|
padding: 1.25rem;
|
|
574
584
|
overflow: auto;
|
|
575
585
|
overscroll-behavior: contain;
|
|
586
|
+
/* It scrolls — a finger, a wheel — with no bar showing. */
|
|
587
|
+
scrollbar-width: none;
|
|
588
|
+
}
|
|
589
|
+
[data-pg-reels-panel-detail]::-webkit-scrollbar {
|
|
590
|
+
display: none;
|
|
576
591
|
}
|
|
577
592
|
/* Variants: only the chosen one's gallery shows. */
|
|
578
593
|
[data-pg-reels-panel] [data-pg-reels-gallery]:not([data-pg-reels-current]) {
|
package/index.ts
CHANGED
|
@@ -709,9 +709,33 @@ export function initReels(): () => void {
|
|
|
709
709
|
const current = (): Group => view.list[view.gi];
|
|
710
710
|
let headOf: Group | null = null;
|
|
711
711
|
|
|
712
|
+
// A clip's still: a video's poster, or the picture itself.
|
|
713
|
+
const stillOf = (clip: HTMLElement | undefined): string =>
|
|
714
|
+
clip?.querySelector("video")?.getAttribute("poster") || clip?.querySelector("img")?.getAttribute("src") || "";
|
|
715
|
+
// The stills shown next — the groups beside the one shown, the ones
|
|
716
|
+
// beside those, the clip after this one — fetched and decoded ahead: a
|
|
717
|
+
// group sliding in, the one coming in under it, the next clip, are
|
|
718
|
+
// never blank first.
|
|
719
|
+
const warmed = new Set<string>();
|
|
720
|
+
const warm = (clip: HTMLElement | undefined): void => {
|
|
721
|
+
const src = stillOf(clip);
|
|
722
|
+
if (!src || warmed.has(src)) return;
|
|
723
|
+
warmed.add(src);
|
|
724
|
+
const img = new Image();
|
|
725
|
+
img.src = src;
|
|
726
|
+
img.decode?.().catch(() => {});
|
|
727
|
+
};
|
|
728
|
+
// Its still behind it too, painted at once from the cache, until the
|
|
729
|
+
// video's own poster and frames are there.
|
|
730
|
+
const backed = (holder: HTMLElement, clip: HTMLElement | undefined): void => {
|
|
731
|
+
const src = stillOf(clip);
|
|
732
|
+
holder.style.background = src ? `#000 url(${JSON.stringify(src)}) center / cover no-repeat` : "";
|
|
733
|
+
};
|
|
734
|
+
|
|
712
735
|
// A group's first clip, for the video above or under the one shown:
|
|
713
736
|
// a picture, or a video on its poster — never playing.
|
|
714
737
|
const peekOf = (holder: HTMLElement, g: Group | undefined): void => {
|
|
738
|
+
backed(holder, g?.clips[0]);
|
|
715
739
|
holder.replaceChildren(...(g ? [copyOf(g.clips[0])] : []));
|
|
716
740
|
holder.hidden = !g;
|
|
717
741
|
holder.querySelectorAll("video").forEach((x) => {
|
|
@@ -770,9 +794,12 @@ export function initReels(): () => void {
|
|
|
770
794
|
v.preload = "auto";
|
|
771
795
|
v.loop = false;
|
|
772
796
|
}
|
|
797
|
+
backed(media, clip);
|
|
773
798
|
media.replaceChildren(copy);
|
|
774
799
|
peekOf(before, view.list[view.gi - 1]);
|
|
775
800
|
peekOf(after, view.list[view.gi + 1]);
|
|
801
|
+
[-2, -1, 1, 2].forEach((d) => warm(view.list[view.gi + d]?.clips[0]));
|
|
802
|
+
warm(g.clips[view.ci + 1]);
|
|
776
803
|
|
|
777
804
|
const product = g.products[view.ci];
|
|
778
805
|
part("panel-summary").replaceChildren(...(product ? [copyOf(product)] : []));
|
|
@@ -975,8 +1002,10 @@ export function initReels(): () => void {
|
|
|
975
1002
|
press = null;
|
|
976
1003
|
const g = current();
|
|
977
1004
|
if (g) show(g, view.ci);
|
|
978
|
-
//
|
|
979
|
-
|
|
1005
|
+
// Closed, the cards are all muted again — the full view's sound
|
|
1006
|
+
// stays in it, whichever card it came from.
|
|
1007
|
+
sound = false;
|
|
1008
|
+
owner = null;
|
|
980
1009
|
if (dialog.open) dialog.close();
|
|
981
1010
|
media.replaceChildren();
|
|
982
1011
|
if (view.pushed && !byBack) history.back();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusguard/reels",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Shoppable reels for a store: a strip of video cards — each a group of clips, each clip with its own product — that opens into a full view. Up and down between groups, left and right within one, the product beside the video on a computer and under it on a phone. No dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|