@depict-ai/portal-components 2.7.32 → 2.7.33
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/index.d.ts +1 -1
- package/dist/main.js +27 -22
- package/dist/module.js +27 -22
- package/package.json +1 -1
- package/src/specialForShopify/DefaultSolidProductCard.tsx +35 -23
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { SearchFilter } from "@depict-ai/types/api/SearchResponse";
|
|
|
4
4
|
import { Locale } from "@depict-ai/react-ui/locales/latest";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
|
|
7
|
-
export const version = "2.7.
|
|
7
|
+
export const version = "2.7.33";
|
|
8
8
|
type TextOptions = {
|
|
9
9
|
/** Enabled */
|
|
10
10
|
enabled: boolean;
|
package/dist/main.js
CHANGED
|
@@ -20,7 +20,7 @@ $parcel$export(module.exports, "ExpandingSection", () => $2214dc111b9e2866$expor
|
|
|
20
20
|
$parcel$export(module.exports, "ReactLookCard", () => $35bab9ff48bfe404$export$48787da2a5568bc);
|
|
21
21
|
$parcel$export(module.exports, "version", () => $0a017be3a74fcc94$export$83d89fbfd8236492);
|
|
22
22
|
/*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
|
|
23
|
-
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.
|
|
23
|
+
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.33";
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
@@ -196,8 +196,6 @@ overrideAspectRatio) {
|
|
|
196
196
|
"--alignment": alignment
|
|
197
197
|
};
|
|
198
198
|
};
|
|
199
|
-
(0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
|
|
200
|
-
(0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
|
|
201
199
|
(0, $7jsgb$solidjs.createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
202
200
|
// For switch from placeholders to product
|
|
203
201
|
(0, $7jsgb$solidjs.createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
|
|
@@ -639,12 +637,22 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
639
637
|
];
|
|
640
638
|
const productCardIsVisible = (0, $7jsgb$depictaiuilatest.useProductCardIsVisible)();
|
|
641
639
|
const hasBeenVisible = (0, $7jsgb$solidjs.createMemo)((prev)=>prev || productCardIsVisible() || forceIsVisible_());
|
|
640
|
+
const video_urls = ()=>video_()?.video_urls;
|
|
641
|
+
const hasVideo = (0, $7jsgb$solidjs.createMemo)(()=>video_urls()?.length);
|
|
642
|
+
const hoverImageDisabled = (0, $7jsgb$solidjs.createMemo)(()=>!configuredOptions_().use_hover_image || noHoverSupport_());
|
|
643
|
+
const hasEnoughImagesForSlider = (0, $7jsgb$solidjs.createMemo)((prev)=>{
|
|
644
|
+
if (prev) return prev; // If we had it once, keep the slider (since removing it is not expected by some code IIRC and could look glitchy)
|
|
645
|
+
let minImagesAvailableToEnableSwipe = 2;
|
|
646
|
+
if (hasVideo()) minImagesAvailableToEnableSwipe--;
|
|
647
|
+
else if (!hoverImageDisabled()) minImagesAvailableToEnableSwipe++;
|
|
648
|
+
return image_urls_()?.length >= minImagesAvailableToEnableSwipe;
|
|
649
|
+
});
|
|
642
650
|
const slidable = (0, $7jsgb$solidjs.createMemo)(()=>// Don't make cards swipable inside of sliders (PLP slider or recs slider)
|
|
643
651
|
!((0, $7jsgb$depictaiuilatest.useSlidableInformation)() || PLPLayout?.()?.startsWith("slider")) && configuredOptions_().image_carousel && // Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const video_urls = ()=>video_()?.video_urls;
|
|
652
|
+
// Don't delay the creation of the slider if there's a video, since (contrary to what I've observed with images) the move of the video in the DOM will abort the playback, which will abort the network request, which delays the playback of the video significantly
|
|
653
|
+
(hasBeenVisible() || hasVideo()) && hasEnoughImagesForSlider());
|
|
647
654
|
const [userTriedSliding, setUserTriedSliding] = (0, $7jsgb$solidjs.createSignal)(false);
|
|
655
|
+
const [swipedPastVideo_, setSwipedPastVideo] = (0, $7jsgb$solidjs.createSignal)(false);
|
|
648
656
|
const Container = (props)=>{
|
|
649
657
|
const resolved = (0, $7jsgb$solidjs.children)(()=>props.children);
|
|
650
658
|
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
@@ -704,8 +712,13 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
704
712
|
// Actually render (and load) the other images when the slider gets swiped
|
|
705
713
|
slidableInformation.intersectionEntries_(); // Re-check when intersecting entries change
|
|
706
714
|
const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
|
|
707
|
-
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
708
715
|
if (1 in intersectingsObject) setUserTriedSliding(true);
|
|
716
|
+
// Pause video when swiping to the next image
|
|
717
|
+
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
718
|
+
if (!intersectingsObject || !Object.keys(intersectingsObject).length) return;
|
|
719
|
+
// Video is always the first card in the slider
|
|
720
|
+
const ratio = intersectingsObject?.[0]?.intersectionRatio;
|
|
721
|
+
setSwipedPastVideo(!ratio);
|
|
709
722
|
});
|
|
710
723
|
return resolved;
|
|
711
724
|
})();
|
|
@@ -753,7 +766,7 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
753
766
|
return [
|
|
754
767
|
(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
755
768
|
get when () {
|
|
756
|
-
return
|
|
769
|
+
return hasVideo();
|
|
757
770
|
},
|
|
758
771
|
get children () {
|
|
759
772
|
return (0, $7jsgb$solidjsweb.createComponent)(MaybeShowLazily, {
|
|
@@ -773,6 +786,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
773
786
|
},
|
|
774
787
|
get forceIsVisible_ () {
|
|
775
788
|
return forceIsVisible_();
|
|
789
|
+
},
|
|
790
|
+
get swipedPastVideo_ () {
|
|
791
|
+
return swipedPastVideo_();
|
|
776
792
|
}
|
|
777
793
|
});
|
|
778
794
|
}
|
|
@@ -784,7 +800,7 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
784
800
|
}),
|
|
785
801
|
(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
786
802
|
get when () {
|
|
787
|
-
return !
|
|
803
|
+
return !hasVideo() || slidable();
|
|
788
804
|
},
|
|
789
805
|
get children () {
|
|
790
806
|
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
|
|
@@ -858,24 +874,13 @@ function $3375ddd88f77967d$var$Video(props) {
|
|
|
858
874
|
return sources;
|
|
859
875
|
});
|
|
860
876
|
const productCardIndexAccessor = (0, $7jsgb$depictaiuilatest.useProductCardIndex)();
|
|
861
|
-
const
|
|
862
|
-
const slidableInformation = (0, $7jsgb$depictaiuilatest.useSlidableInformation)();
|
|
863
|
-
const hiddenInImageCarousel = (0, $7jsgb$solidjs.createMemo)(()=>{
|
|
864
|
-
// Pause video when swiping to the next image
|
|
865
|
-
slidableInformation?.intersectionEntries_(); // Re-check when intersecting entries change
|
|
866
|
-
const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
|
|
867
|
-
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
868
|
-
if (!intersectingsObject || !Object.keys(intersectingsObject).length) return false;
|
|
869
|
-
// Video is always the first card in the slider
|
|
870
|
-
const ratio = intersectingsObject?.[0]?.intersectionRatio;
|
|
871
|
-
return !ratio;
|
|
872
|
-
});
|
|
877
|
+
const cardIsVisible = (0, $7jsgb$depictaiuilatest.useProductCardIsVisible)();
|
|
873
878
|
return (()=>{
|
|
874
879
|
var _el$17 = $3375ddd88f77967d$var$_tmpl$15();
|
|
875
880
|
(0, $7jsgb$solidjsweb.use)((element)=>{
|
|
876
881
|
element.disablePictureInPicture = true;
|
|
877
882
|
(0, $7jsgb$solidjs.createEffect)(()=>{
|
|
878
|
-
if ((
|
|
883
|
+
if ((cardIsVisible() || props.forceIsVisible_) && tabIsVisible() && !props.swipedPastVideo_) element.play().catch((e)=>(0, $7jsgb$depictaiutilisharedlatest.dwarn)("Error playing video", e));
|
|
879
884
|
else element.pause();
|
|
880
885
|
});
|
|
881
886
|
}, _el$17);
|
package/dist/module.js
CHANGED
|
@@ -7,7 +7,7 @@ import {createContext as $2MCgq$createContext, createMemo as $2MCgq$createMemo,
|
|
|
7
7
|
import {createPortal as $2MCgq$createPortal} from "react-dom";
|
|
8
8
|
|
|
9
9
|
/*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
|
|
10
|
-
const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.
|
|
10
|
+
const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.33";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -183,8 +183,6 @@ overrideAspectRatio) {
|
|
|
183
183
|
"--alignment": alignment
|
|
184
184
|
};
|
|
185
185
|
};
|
|
186
|
-
(0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
|
|
187
|
-
(0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
|
|
188
186
|
(0, $2MCgq$createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
189
187
|
// For switch from placeholders to product
|
|
190
188
|
(0, $2MCgq$createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
|
|
@@ -626,12 +624,22 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
626
624
|
];
|
|
627
625
|
const productCardIsVisible = (0, $2MCgq$useProductCardIsVisible)();
|
|
628
626
|
const hasBeenVisible = (0, $2MCgq$createMemo)((prev)=>prev || productCardIsVisible() || forceIsVisible_());
|
|
627
|
+
const video_urls = ()=>video_()?.video_urls;
|
|
628
|
+
const hasVideo = (0, $2MCgq$createMemo)(()=>video_urls()?.length);
|
|
629
|
+
const hoverImageDisabled = (0, $2MCgq$createMemo)(()=>!configuredOptions_().use_hover_image || noHoverSupport_());
|
|
630
|
+
const hasEnoughImagesForSlider = (0, $2MCgq$createMemo)((prev)=>{
|
|
631
|
+
if (prev) return prev; // If we had it once, keep the slider (since removing it is not expected by some code IIRC and could look glitchy)
|
|
632
|
+
let minImagesAvailableToEnableSwipe = 2;
|
|
633
|
+
if (hasVideo()) minImagesAvailableToEnableSwipe--;
|
|
634
|
+
else if (!hoverImageDisabled()) minImagesAvailableToEnableSwipe++;
|
|
635
|
+
return image_urls_()?.length >= minImagesAvailableToEnableSwipe;
|
|
636
|
+
});
|
|
629
637
|
const slidable = (0, $2MCgq$createMemo)(()=>// Don't make cards swipable inside of sliders (PLP slider or recs slider)
|
|
630
638
|
!((0, $2MCgq$useSlidableInformation)() || PLPLayout?.()?.startsWith("slider")) && configuredOptions_().image_carousel && // Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
const video_urls = ()=>video_()?.video_urls;
|
|
639
|
+
// Don't delay the creation of the slider if there's a video, since (contrary to what I've observed with images) the move of the video in the DOM will abort the playback, which will abort the network request, which delays the playback of the video significantly
|
|
640
|
+
(hasBeenVisible() || hasVideo()) && hasEnoughImagesForSlider());
|
|
634
641
|
const [userTriedSliding, setUserTriedSliding] = (0, $2MCgq$createSignal)(false);
|
|
642
|
+
const [swipedPastVideo_, setSwipedPastVideo] = (0, $2MCgq$createSignal)(false);
|
|
635
643
|
const Container = (props)=>{
|
|
636
644
|
const resolved = (0, $2MCgq$children)(()=>props.children);
|
|
637
645
|
return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
@@ -691,8 +699,13 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
691
699
|
// Actually render (and load) the other images when the slider gets swiped
|
|
692
700
|
slidableInformation.intersectionEntries_(); // Re-check when intersecting entries change
|
|
693
701
|
const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
|
|
694
|
-
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
695
702
|
if (1 in intersectingsObject) setUserTriedSliding(true);
|
|
703
|
+
// Pause video when swiping to the next image
|
|
704
|
+
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
705
|
+
if (!intersectingsObject || !Object.keys(intersectingsObject).length) return;
|
|
706
|
+
// Video is always the first card in the slider
|
|
707
|
+
const ratio = intersectingsObject?.[0]?.intersectionRatio;
|
|
708
|
+
setSwipedPastVideo(!ratio);
|
|
696
709
|
});
|
|
697
710
|
return resolved;
|
|
698
711
|
})();
|
|
@@ -740,7 +753,7 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
740
753
|
return [
|
|
741
754
|
(0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
742
755
|
get when () {
|
|
743
|
-
return
|
|
756
|
+
return hasVideo();
|
|
744
757
|
},
|
|
745
758
|
get children () {
|
|
746
759
|
return (0, $2MCgq$createComponent)(MaybeShowLazily, {
|
|
@@ -760,6 +773,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
760
773
|
},
|
|
761
774
|
get forceIsVisible_ () {
|
|
762
775
|
return forceIsVisible_();
|
|
776
|
+
},
|
|
777
|
+
get swipedPastVideo_ () {
|
|
778
|
+
return swipedPastVideo_();
|
|
763
779
|
}
|
|
764
780
|
});
|
|
765
781
|
}
|
|
@@ -771,7 +787,7 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
771
787
|
}),
|
|
772
788
|
(0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
773
789
|
get when () {
|
|
774
|
-
return !
|
|
790
|
+
return !hasVideo() || slidable();
|
|
775
791
|
},
|
|
776
792
|
get children () {
|
|
777
793
|
return (0, $2MCgq$createComponent)((0, $2MCgq$For), {
|
|
@@ -845,24 +861,13 @@ function $29535f590238371c$var$Video(props) {
|
|
|
845
861
|
return sources;
|
|
846
862
|
});
|
|
847
863
|
const productCardIndexAccessor = (0, $2MCgq$useProductCardIndex)();
|
|
848
|
-
const
|
|
849
|
-
const slidableInformation = (0, $2MCgq$useSlidableInformation)();
|
|
850
|
-
const hiddenInImageCarousel = (0, $2MCgq$createMemo)(()=>{
|
|
851
|
-
// Pause video when swiping to the next image
|
|
852
|
-
slidableInformation?.intersectionEntries_(); // Re-check when intersecting entries change
|
|
853
|
-
const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
|
|
854
|
-
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
855
|
-
if (!intersectingsObject || !Object.keys(intersectingsObject).length) return false;
|
|
856
|
-
// Video is always the first card in the slider
|
|
857
|
-
const ratio = intersectingsObject?.[0]?.intersectionRatio;
|
|
858
|
-
return !ratio;
|
|
859
|
-
});
|
|
864
|
+
const cardIsVisible = (0, $2MCgq$useProductCardIsVisible)();
|
|
860
865
|
return (()=>{
|
|
861
866
|
var _el$17 = $29535f590238371c$var$_tmpl$15();
|
|
862
867
|
(0, $2MCgq$use)((element)=>{
|
|
863
868
|
element.disablePictureInPicture = true;
|
|
864
869
|
(0, $2MCgq$createEffect)(()=>{
|
|
865
|
-
if ((
|
|
870
|
+
if ((cardIsVisible() || props.forceIsVisible_) && tabIsVisible() && !props.swipedPastVideo_) element.play().catch((e)=>(0, $2MCgq$dwarn)("Error playing video", e));
|
|
866
871
|
else element.pause();
|
|
867
872
|
});
|
|
868
873
|
}, _el$17);
|
package/package.json
CHANGED
|
@@ -243,9 +243,6 @@ export function DefaultSolidProductCard(
|
|
|
243
243
|
return { "--flex-alignment": flexAlignment, "--alignment": alignment };
|
|
244
244
|
};
|
|
245
245
|
|
|
246
|
-
createEffect(() => dlog("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
|
|
247
|
-
createEffect(() => dlog("Got passed display", JSON.parse(JSON.stringify(display()))));
|
|
248
|
-
|
|
249
246
|
createEffect(() => noHoverSupport_() && setCardIsHovered(false));
|
|
250
247
|
// For switch from placeholders to product
|
|
251
248
|
createEffect(
|
|
@@ -694,17 +691,31 @@ function ImagesAndVideos({
|
|
|
694
691
|
const containerClasses = () => ["image-video", "border-radius-" + configuredOptions_().image_radius] as const;
|
|
695
692
|
const productCardIsVisible = useProductCardIsVisible();
|
|
696
693
|
const hasBeenVisible = createMemo<boolean | undefined>(prev => prev || productCardIsVisible() || forceIsVisible_());
|
|
694
|
+
const video_urls = () => video_()?.video_urls;
|
|
695
|
+
const hasVideo = createMemo(() => video_urls()?.length);
|
|
696
|
+
const hoverImageDisabled = createMemo(() => !configuredOptions_().use_hover_image || noHoverSupport_());
|
|
697
|
+
const hasEnoughImagesForSlider = createMemo<boolean | undefined>(prev => {
|
|
698
|
+
if (prev) return prev; // If we had it once, keep the slider (since removing it is not expected by some code IIRC and could look glitchy)
|
|
699
|
+
let minImagesAvailableToEnableSwipe = 2;
|
|
700
|
+
if (hasVideo()) {
|
|
701
|
+
minImagesAvailableToEnableSwipe--;
|
|
702
|
+
} else if (!hoverImageDisabled()) {
|
|
703
|
+
minImagesAvailableToEnableSwipe++;
|
|
704
|
+
}
|
|
705
|
+
return (image_urls_()?.length as number) >= minImagesAvailableToEnableSwipe;
|
|
706
|
+
});
|
|
697
707
|
const slidable = createMemo(
|
|
698
708
|
() =>
|
|
699
709
|
// Don't make cards swipable inside of sliders (PLP slider or recs slider)
|
|
700
710
|
!(useSlidableInformation() || PLPLayout?.()?.startsWith("slider")) &&
|
|
701
711
|
configuredOptions_().image_carousel &&
|
|
702
712
|
// Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
|
|
703
|
-
|
|
713
|
+
// Don't delay the creation of the slider if there's a video, since (contrary to what I've observed with images) the move of the video in the DOM will abort the playback, which will abort the network request, which delays the playback of the video significantly
|
|
714
|
+
(hasBeenVisible() || hasVideo()) &&
|
|
715
|
+
hasEnoughImagesForSlider()
|
|
704
716
|
);
|
|
705
|
-
const hoverImageDisabled = createMemo(() => !configuredOptions_().use_hover_image || noHoverSupport_());
|
|
706
|
-
const video_urls = () => video_()?.video_urls;
|
|
707
717
|
const [userTriedSliding, setUserTriedSliding] = createSignal(false);
|
|
718
|
+
const [swipedPastVideo_, setSwipedPastVideo] = createSignal(false);
|
|
708
719
|
|
|
709
720
|
const Container = (props: { children: JSX.Element }) => {
|
|
710
721
|
const resolved = children(() => props.children);
|
|
@@ -758,10 +769,16 @@ function ImagesAndVideos({
|
|
|
758
769
|
// Actually render (and load) the other images when the slider gets swiped
|
|
759
770
|
slidableInformation!.intersectionEntries_(); // Re-check when intersecting entries change
|
|
760
771
|
const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
|
|
761
|
-
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
762
772
|
if (1 in intersectingsObject!) {
|
|
763
773
|
setUserTriedSliding(true);
|
|
764
774
|
}
|
|
775
|
+
|
|
776
|
+
// Pause video when swiping to the next image
|
|
777
|
+
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
778
|
+
if (!intersectingsObject || !Object.keys(intersectingsObject).length) return;
|
|
779
|
+
// Video is always the first card in the slider
|
|
780
|
+
const ratio = intersectingsObject?.[0]?.intersectionRatio;
|
|
781
|
+
setSwipedPastVideo(!ratio);
|
|
765
782
|
});
|
|
766
783
|
|
|
767
784
|
return resolved as unknown as JSX.Element;
|
|
@@ -793,7 +810,7 @@ function ImagesAndVideos({
|
|
|
793
810
|
return (
|
|
794
811
|
<Show when={image_urls_()} fallback={<ImagePlaceholder aspectRatio={aspectRatio_()} />}>
|
|
795
812
|
<Container>
|
|
796
|
-
<Show when={
|
|
813
|
+
<Show when={hasVideo()}>
|
|
797
814
|
<MaybeShowLazily>
|
|
798
815
|
<div class="media-item video">
|
|
799
816
|
<ImageContainer aspectRatio={aspectRatio_()}>
|
|
@@ -801,12 +818,13 @@ function ImagesAndVideos({
|
|
|
801
818
|
video_sources_={video_urls() as [string, ...string[]]}
|
|
802
819
|
poster_={video_()?.preview_image_url || image_urls_()?.[0]}
|
|
803
820
|
forceIsVisible_={forceIsVisible_()}
|
|
821
|
+
swipedPastVideo_={swipedPastVideo_()}
|
|
804
822
|
/>
|
|
805
823
|
</ImageContainer>
|
|
806
824
|
</div>
|
|
807
825
|
</MaybeShowLazily>
|
|
808
826
|
</Show>
|
|
809
|
-
<Show when={!
|
|
827
|
+
<Show when={!hasVideo() || slidable()}>
|
|
810
828
|
<For each={slidable() ? image_urls_() : image_urls_()?.slice(0, 1)}>
|
|
811
829
|
{(image_url, index) => (
|
|
812
830
|
<Show when={hoverImageDisabled() || index() !== 1}>
|
|
@@ -839,7 +857,12 @@ function ImagesAndVideos({
|
|
|
839
857
|
);
|
|
840
858
|
}
|
|
841
859
|
|
|
842
|
-
function Video(props: {
|
|
860
|
+
function Video(props: {
|
|
861
|
+
video_sources_: [string, ...string[]];
|
|
862
|
+
poster_?: string;
|
|
863
|
+
forceIsVisible_?: boolean;
|
|
864
|
+
swipedPastVideo_: boolean;
|
|
865
|
+
}) {
|
|
843
866
|
// Making some assumptions for shopify here rn, change those if wanting to support other browsers too
|
|
844
867
|
|
|
845
868
|
const tabIsVisible = useVisibilityState();
|
|
@@ -855,18 +878,7 @@ function Video(props: { video_sources_: [string, ...string[]]; poster_?: string;
|
|
|
855
878
|
return sources;
|
|
856
879
|
});
|
|
857
880
|
const productCardIndexAccessor = useProductCardIndex();
|
|
858
|
-
const
|
|
859
|
-
const slidableInformation = useSlidableInformation();
|
|
860
|
-
const hiddenInImageCarousel = createMemo(() => {
|
|
861
|
-
// Pause video when swiping to the next image
|
|
862
|
-
slidableInformation?.intersectionEntries_(); // Re-check when intersecting entries change
|
|
863
|
-
const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
|
|
864
|
-
// If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
|
|
865
|
-
if (!intersectingsObject || !Object.keys(intersectingsObject).length) return false;
|
|
866
|
-
// Video is always the first card in the slider
|
|
867
|
-
const ratio = intersectingsObject?.[0]?.intersectionRatio;
|
|
868
|
-
return !ratio;
|
|
869
|
-
});
|
|
881
|
+
const cardIsVisible = useProductCardIsVisible();
|
|
870
882
|
|
|
871
883
|
return (
|
|
872
884
|
<video
|
|
@@ -880,7 +892,7 @@ function Video(props: { video_sources_: [string, ...string[]]; poster_?: string;
|
|
|
880
892
|
ref={element => {
|
|
881
893
|
element.disablePictureInPicture = true;
|
|
882
894
|
createEffect(() => {
|
|
883
|
-
if ((
|
|
895
|
+
if ((cardIsVisible() || props.forceIsVisible_) && tabIsVisible() && !props.swipedPastVideo_) {
|
|
884
896
|
element.play().catch(e => dwarn("Error playing video", e));
|
|
885
897
|
} else {
|
|
886
898
|
element.pause();
|