@gxpl/sdk 0.0.35 → 0.0.36-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/lib/sdk-nextjs/components/Page.js +3 -2
- package/lib/sdk-nextjs/components/Section/SectionVideo.js +55 -23
- package/lib/sdk-nextjs/components/Section/SectionVideoCacheContext.d.ts +10 -0
- package/lib/sdk-nextjs/components/Section/SectionVideoCacheContext.js +43 -0
- package/lib/sdk-nextjs/components/items/FileItem/ImageItem.js +15 -3
- package/lib/sdk-nextjs/components/items/FileItem/VideoItem.js +42 -40
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ const TransitionMachineContext_1 = require("../provider/TransitionMachineContext
|
|
|
11
11
|
const Scenes_1 = require("./Scenes/Scenes");
|
|
12
12
|
const FixedLayer_1 = require("./fixedLayers/FixedLayer");
|
|
13
13
|
const usePrelaodAssets_1 = require("../utils/usePrelaodAssets");
|
|
14
|
+
const SectionVideoCacheContext_1 = require("./Section/SectionVideoCacheContext");
|
|
14
15
|
const Page = ({ project, articlesData }) => {
|
|
15
16
|
var _a, _b;
|
|
16
17
|
const afterBodyOpen = (0, html_react_parser_1.default)(project.html.afterBodyOpen);
|
|
@@ -19,12 +20,12 @@ const Page = ({ project, articlesData }) => {
|
|
|
19
20
|
const scenes = Object.values(articlesData).map(({ article }) => ({ id: article.id }));
|
|
20
21
|
const { relations, scenesAssets } = project;
|
|
21
22
|
(0, usePrelaodAssets_1.usePreloadAssets)(scenesAssets);
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Head_1.CNTRLHead, { project: project }), afterBodyOpen, (0, jsx_runtime_1.
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Head_1.CNTRLHead, { project: project }), afterBodyOpen, (0, jsx_runtime_1.jsx)(TransitionMachineContext_1.TransitionMachineContext.Provider, { options: {
|
|
23
24
|
input: {
|
|
24
25
|
startScene,
|
|
25
26
|
relations,
|
|
26
27
|
scenes,
|
|
27
28
|
}
|
|
28
|
-
}, children: [project.foreground && !project.foreground.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.foreground, type: "foreground" }), (0, jsx_runtime_1.jsx)(Scenes_1.Scenes, { articlesData: articlesData }), project.background && !project.background.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.background, type: "background" })] }), beforeBodyClose] }));
|
|
29
|
+
}, children: (0, jsx_runtime_1.jsxs)(SectionVideoCacheContext_1.SectionVideoCacheProvider, { assets: scenesAssets, children: [project.foreground && !project.foreground.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.foreground, type: "foreground" }), (0, jsx_runtime_1.jsx)(Scenes_1.Scenes, { articlesData: articlesData }), project.background && !project.background.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.background, type: "background" })] }) }), beforeBodyClose] }));
|
|
29
30
|
};
|
|
30
31
|
exports.Page = Page;
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SectionVideo = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const SectionVideoCacheContext_1 = require("./SectionVideoCacheContext");
|
|
6
7
|
const SectionVideo = ({ container, sectionId, media }) => {
|
|
7
8
|
const [video, setVideo] = (0, react_1.useState)(null);
|
|
9
|
+
const { videoCache } = (0, react_1.useContext)(SectionVideoCacheContext_1.SectionVideoCacheContext);
|
|
8
10
|
const [videoWrapper, setVideoWrapper] = (0, react_1.useState)(null);
|
|
9
11
|
const [isVideoWidthOverflow, setIsVideoWidthOverflow] = (0, react_1.useState)(false);
|
|
10
12
|
const { url, size, position, offsetX, coverUrl, play } = media;
|
|
@@ -24,6 +26,42 @@ const SectionVideo = ({ container, sectionId, media }) => {
|
|
|
24
26
|
setUserPaused(false);
|
|
25
27
|
}
|
|
26
28
|
};
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
if (!videoWrapper)
|
|
31
|
+
return;
|
|
32
|
+
const video = videoCache.get(url);
|
|
33
|
+
if (!video)
|
|
34
|
+
return;
|
|
35
|
+
video.controls = play === "on-click";
|
|
36
|
+
video.muted = play === "auto";
|
|
37
|
+
video.autoplay = play === "auto";
|
|
38
|
+
video.loop = true;
|
|
39
|
+
const style = {
|
|
40
|
+
objectFit: isContainHeight ? 'cover' : (size !== null && size !== void 0 ? size : 'cover'),
|
|
41
|
+
width: isContainHeight && !isVideoWidthOverflow ? 'auto' : '100%',
|
|
42
|
+
transform: isContainHeight ? 'translateX(-50%)' : 'none',
|
|
43
|
+
left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
|
|
44
|
+
height: '100%',
|
|
45
|
+
position: 'relative'
|
|
46
|
+
};
|
|
47
|
+
Object.assign(video.style, style);
|
|
48
|
+
if (!videoWrapper.contains(video)) {
|
|
49
|
+
videoWrapper.appendChild(video);
|
|
50
|
+
}
|
|
51
|
+
setVideo(video);
|
|
52
|
+
video.addEventListener('play', () => {
|
|
53
|
+
setIsPlaying(true);
|
|
54
|
+
});
|
|
55
|
+
video.addEventListener('pause', () => {
|
|
56
|
+
setIsPlaying(false);
|
|
57
|
+
});
|
|
58
|
+
if (play === "auto") {
|
|
59
|
+
video.play().catch(() => { });
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
video.pause();
|
|
63
|
+
};
|
|
64
|
+
}, [url, play, videoWrapper, videoCache, sectionId, video, isVideoWidthOverflow]);
|
|
27
65
|
(0, react_1.useEffect)(() => {
|
|
28
66
|
if (!video || play !== 'on-click')
|
|
29
67
|
return;
|
|
@@ -44,6 +82,7 @@ const SectionVideo = ({ container, sectionId, media }) => {
|
|
|
44
82
|
if (!video || !videoWrapper)
|
|
45
83
|
return;
|
|
46
84
|
video.addEventListener('loadedmetadata', () => {
|
|
85
|
+
console.log('loadedmetadata', video.videoHeight, video.videoWidth);
|
|
47
86
|
const h = video.videoHeight;
|
|
48
87
|
const w = video.videoWidth;
|
|
49
88
|
const width = (videoWrapper.clientHeight / h) * w;
|
|
@@ -57,35 +96,28 @@ const SectionVideo = ({ container, sectionId, media }) => {
|
|
|
57
96
|
}, [video, videoWrapper]);
|
|
58
97
|
const isContainHeight = size === 'contain-height';
|
|
59
98
|
const hasOffsetX = offsetX !== null && size === 'contain';
|
|
60
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.
|
|
99
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { ref: setVideoWrapper, className: `section-video-wrapper-${sectionId}`, style: {
|
|
61
100
|
position: position === 'fixed' ? 'sticky' : 'relative',
|
|
62
101
|
height: position === 'fixed' ? '100vh' : '100%',
|
|
63
102
|
top: position === 'fixed' ? '100vh' : '0',
|
|
64
103
|
overflow: 'hidden',
|
|
104
|
+
opacity: !isClickedOnCover && play === 'on-click' && coverUrl ? 0 : 1,
|
|
65
105
|
width: '100%'
|
|
66
|
-
}, children:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
106
|
+
}, children: play === 'on-click' && !isClickedOnCover && ((0, jsx_runtime_1.jsx)("div", { className: `video-background-${sectionId}-cover-container`, style: {
|
|
107
|
+
position: 'absolute',
|
|
108
|
+
left: 0,
|
|
109
|
+
width: '100%',
|
|
110
|
+
height: '100%',
|
|
111
|
+
top: 0
|
|
112
|
+
}, onClick: handleCoverClick, children: coverUrl && play === 'on-click' && ((0, jsx_runtime_1.jsx)("img", { src: coverUrl, alt: "Video cover", className: `video-background-${sectionId}-cover`, style: {
|
|
113
|
+
opacity: isPlaying ? 0 : 1,
|
|
71
114
|
left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
|
|
115
|
+
width: isContainHeight ? 'auto' : '100%',
|
|
116
|
+
objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
|
|
117
|
+
transform: isContainHeight ? 'translateX(-50%)' : 'none',
|
|
118
|
+
position: 'relative',
|
|
72
119
|
height: '100%',
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
position: 'absolute',
|
|
76
|
-
left: 0,
|
|
77
|
-
width: '100%',
|
|
78
|
-
height: '100%',
|
|
79
|
-
top: 0
|
|
80
|
-
}, onClick: handleCoverClick, children: coverUrl && play === 'on-click' && ((0, jsx_runtime_1.jsx)("img", { src: coverUrl, alt: "Video cover", className: `video-background-${sectionId}-cover`, style: {
|
|
81
|
-
opacity: isPlaying ? 0 : 1,
|
|
82
|
-
left: isContainHeight ? '50%' : (hasOffsetX ? `${offsetX * 100}vw` : '0'),
|
|
83
|
-
width: isContainHeight ? 'auto' : '100%',
|
|
84
|
-
objectFit: isContainHeight ? 'unset' : (size !== null && size !== void 0 ? size : 'cover'),
|
|
85
|
-
transform: isContainHeight ? 'translateX(-50%)' : 'none',
|
|
86
|
-
position: 'relative',
|
|
87
|
-
height: '100%',
|
|
88
|
-
transition: 'opacity 0.1s ease-in-out'
|
|
89
|
-
} })) }))] }) }));
|
|
120
|
+
transition: 'opacity 0.1s ease-in-out'
|
|
121
|
+
} })) })) }) }));
|
|
90
122
|
};
|
|
91
123
|
exports.SectionVideo = SectionVideo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
export declare const SectionVideoCacheContext: import("react").Context<{
|
|
3
|
+
videoCache: Map<string, HTMLVideoElement>;
|
|
4
|
+
imageCache: Map<string, HTMLImageElement>;
|
|
5
|
+
}>;
|
|
6
|
+
interface Props {
|
|
7
|
+
assets: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const SectionVideoCacheProvider: FC<PropsWithChildren<Props>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SectionVideoCacheProvider = exports.SectionVideoCacheContext = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
exports.SectionVideoCacheContext = (0, react_1.createContext)({ videoCache: new Map(), imageCache: new Map() });
|
|
7
|
+
const SectionVideoCacheProvider = ({ children, assets }) => {
|
|
8
|
+
const [videoCache, setVideoCache] = (0, react_1.useState)(new Map());
|
|
9
|
+
const [imageCache, setImageCache] = (0, react_1.useState)(new Map());
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
assets.forEach(asset => {
|
|
12
|
+
if (isVideoAsset(asset)) {
|
|
13
|
+
const video = getSectionVideo(asset);
|
|
14
|
+
setVideoCache(prev => prev.set(asset, video));
|
|
15
|
+
}
|
|
16
|
+
if (isImageAsset(asset)) {
|
|
17
|
+
const img = new Image();
|
|
18
|
+
img.src = asset;
|
|
19
|
+
setImageCache(prev => prev.set(asset, img));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}, [assets]);
|
|
23
|
+
return (0, jsx_runtime_1.jsx)(exports.SectionVideoCacheContext.Provider, { value: { videoCache, imageCache }, children: children });
|
|
24
|
+
};
|
|
25
|
+
exports.SectionVideoCacheProvider = SectionVideoCacheProvider;
|
|
26
|
+
function getSectionVideo(url) {
|
|
27
|
+
const video = document.createElement('video');
|
|
28
|
+
video.src = url;
|
|
29
|
+
video.preload = 'auto';
|
|
30
|
+
video.playsInline = true;
|
|
31
|
+
video.load();
|
|
32
|
+
return video;
|
|
33
|
+
}
|
|
34
|
+
function isVideoAsset(url) {
|
|
35
|
+
const videoExtensions = ['.mp4', '.mov', '.webm'];
|
|
36
|
+
const lowerUrl = url.toLowerCase();
|
|
37
|
+
return videoExtensions.some(ext => lowerUrl.endsWith(ext));
|
|
38
|
+
}
|
|
39
|
+
function isImageAsset(url) {
|
|
40
|
+
const imageExtensions = ['.gif', '.png', '.jpg', '.jpeg', '.webp', '.avif', '.svg'];
|
|
41
|
+
const lowerUrl = url.toLowerCase();
|
|
42
|
+
return imageExtensions.some(ext => lowerUrl.endsWith(ext));
|
|
43
|
+
}
|
|
@@ -17,10 +17,12 @@ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromIte
|
|
|
17
17
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
18
18
|
const getFill_1 = require("../../../utils/getFill");
|
|
19
19
|
const useExemplary_1 = require("../../../common/useExemplary");
|
|
20
|
+
const SectionVideoCacheContext_1 = require("../../Section/SectionVideoCacheContext");
|
|
20
21
|
const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
21
22
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
22
23
|
const id = (0, react_1.useId)();
|
|
23
24
|
const { radius: itemRadius, strokeWidth: itemStrokeWidth, opacity: itemOpacity, strokeFill: itemStrokeFill, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
25
|
+
const { imageCache } = (0, react_1.useContext)(SectionVideoCacheContext_1.SectionVideoCacheContext);
|
|
24
26
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
25
27
|
const [wrapperRef, setWrapperRef] = (0, react_1.useState)(null);
|
|
26
28
|
(0, useRegisterResize_1.useRegisterResize)(wrapperRef, onResize);
|
|
@@ -65,9 +67,19 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
65
67
|
(0, react_1.useEffect)(() => {
|
|
66
68
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
67
69
|
}, [isInteractive, onVisibilityChange]);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
(0, react_1.useEffect)(() => {
|
|
71
|
+
if (!wrapperRef)
|
|
72
|
+
return;
|
|
73
|
+
const image = imageCache.get(url);
|
|
74
|
+
if (!image)
|
|
75
|
+
return;
|
|
76
|
+
image.className = `image image-${item.id}`;
|
|
77
|
+
Object.assign(image.style, inlineStyles);
|
|
78
|
+
if (!wrapperRef.contains(image)) {
|
|
79
|
+
wrapperRef.appendChild(image);
|
|
80
|
+
}
|
|
81
|
+
}, [wrapperRef, imageCache, url, angle, blur, inlineStyles]);
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: item.link, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, style: Object.assign(Object.assign({ opacity, transform: `rotate(${angle}deg)` }, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none' }), children: [hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight })), !(hasGLEffect && isFXAllowed) && !imageCache.has(url) && ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id}`, style: inlineStyles, src: item.params.url }))] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
71
83
|
.image-wrapper-${item.id} {
|
|
72
84
|
position: absolute;
|
|
73
85
|
width: 100%;
|
|
@@ -18,16 +18,18 @@ const useElementRect_1 = require("../../../utils/useElementRect");
|
|
|
18
18
|
const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
19
19
|
const getFill_1 = require("../../../utils/getFill");
|
|
20
20
|
const useExemplary_1 = require("../../../common/useExemplary");
|
|
21
|
+
const SectionVideoCacheContext_1 = require("../../Section/SectionVideoCacheContext");
|
|
21
22
|
const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
23
24
|
const id = (0, react_1.useId)();
|
|
24
25
|
const { radius: itemRadius, strokeWidth: itemStrokeWidth, strokeFill: itemStrokeFill, opacity: itemOpacity, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
26
|
+
const { videoCache } = (0, react_1.useContext)(SectionVideoCacheContext_1.SectionVideoCacheContext);
|
|
25
27
|
const [isVideoPlaying, setIsVideoPlaying] = (0, react_1.useState)(false);
|
|
26
28
|
const isScrollPausedRef = (0, react_1.useRef)(false);
|
|
27
29
|
const [userPaused, setUserPaused] = (0, react_1.useState)(false);
|
|
28
30
|
const [isVideoInteracted, setIsVideoInteracted] = (0, react_1.useState)(false);
|
|
29
31
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
30
|
-
const [
|
|
32
|
+
const [videoWrapper, setVideoWrapper] = (0, react_1.useState)(null);
|
|
31
33
|
const [videoRef, setVideoRef] = (0, react_1.useState)(null);
|
|
32
34
|
const fxCanvas = (0, react_1.useRef)(null);
|
|
33
35
|
const { url, hasGLEffect } = item.params;
|
|
@@ -38,7 +40,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
38
40
|
const width = area && exemplary ? area.width * exemplary : 0;
|
|
39
41
|
const height = area && exemplary ? area.height * exemplary : 0;
|
|
40
42
|
const { controlsValues, fragmentShader } = (0, useItemFXData_1.useItemFXData)(item, sectionId);
|
|
41
|
-
const rect = (0, useElementRect_1.useElementRect)(
|
|
43
|
+
const rect = (0, useElementRect_1.useElementRect)(videoWrapper);
|
|
42
44
|
const rectWidth = Math.floor((_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0);
|
|
43
45
|
const rectHeight = Math.floor((_b = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _b !== void 0 ? _b : 0);
|
|
44
46
|
const scrollPlayback = params.scrollPlayback;
|
|
@@ -62,7 +64,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
62
64
|
fragmentShader,
|
|
63
65
|
controls: controlsValues
|
|
64
66
|
}, width, height);
|
|
65
|
-
(0, useRegisterResize_1.useRegisterResize)(
|
|
67
|
+
(0, useRegisterResize_1.useRegisterResize)(videoWrapper, onResize);
|
|
66
68
|
const inlineStyles = Object.assign(Object.assign({ borderRadius: `${radius * 100}vw` }, (strokeWidth !== undefined ? {
|
|
67
69
|
borderWidth: `${strokeWidth * 100}vw`,
|
|
68
70
|
borderColor: stroke,
|
|
@@ -74,53 +76,53 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
74
76
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
75
77
|
}, [isInteractive, onVisibilityChange]);
|
|
76
78
|
(0, react_1.useEffect)(() => {
|
|
77
|
-
|
|
79
|
+
var _a;
|
|
80
|
+
if (!videoWrapper || hasScrollPlayback || hasGLEffect)
|
|
78
81
|
return;
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
const { play } = params;
|
|
83
|
+
const video = videoCache.get(url);
|
|
84
|
+
if (!video)
|
|
85
|
+
return;
|
|
86
|
+
video.controls = play === "on-click";
|
|
87
|
+
video.muted = play === "auto";
|
|
88
|
+
video.autoplay = play === "auto";
|
|
89
|
+
video.loop = true;
|
|
90
|
+
video.poster = (_a = item.params.coverUrl) !== null && _a !== void 0 ? _a : '';
|
|
91
|
+
video.style.transform = `translateZ(0)`;
|
|
92
|
+
video.className = `video video-${item.id}`;
|
|
93
|
+
if (!videoWrapper.contains(video)) {
|
|
94
|
+
videoWrapper.appendChild(video);
|
|
95
|
+
}
|
|
96
|
+
setVideoRef(video);
|
|
97
|
+
video.addEventListener('play', () => {
|
|
98
|
+
setIsVideoPlaying(true);
|
|
99
|
+
setUserPaused(false);
|
|
100
|
+
});
|
|
101
|
+
video.addEventListener('pause', () => {
|
|
102
|
+
if (!isScrollPausedRef.current) {
|
|
103
|
+
setUserPaused(true);
|
|
89
104
|
}
|
|
105
|
+
setIsVideoPlaying(false);
|
|
90
106
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
107
|
+
if (play === "auto") {
|
|
108
|
+
video.play().catch(() => { });
|
|
109
|
+
}
|
|
110
|
+
return () => {
|
|
111
|
+
video.pause();
|
|
112
|
+
};
|
|
113
|
+
}, [params, videoWrapper, videoCache]);
|
|
114
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { link: item.link, children: [(0, jsx_runtime_1.jsxs)("div", { className: `video-wrapper-${item.id}`, ref: setVideoWrapper, style: {
|
|
95
115
|
opacity,
|
|
96
|
-
transform: `rotate(${angle}deg)`,
|
|
116
|
+
transform: `rotate(${angle}deg) translateZ(0)`,
|
|
97
117
|
filter: `blur(${blur * 100}vw)`,
|
|
98
118
|
willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset',
|
|
99
119
|
transition: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none'
|
|
100
|
-
}, children: [hasScrollPlayback && ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.params.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(
|
|
101
|
-
setIsVideoInteracted(true);
|
|
102
|
-
}, muted: params.muted, onPlay: () => {
|
|
103
|
-
setIsVideoPlaying(true);
|
|
104
|
-
setUserPaused(false);
|
|
105
|
-
}, onPause: () => {
|
|
106
|
-
if (!isScrollPausedRef.current) {
|
|
107
|
-
setUserPaused(true);
|
|
108
|
-
}
|
|
109
|
-
setIsVideoPlaying(false);
|
|
110
|
-
}, onMouseEnter: () => {
|
|
111
|
-
if (!videoRef || params.play !== 'on-hover')
|
|
112
|
-
return;
|
|
113
|
-
videoRef.play();
|
|
114
|
-
}, onMouseLeave: () => {
|
|
115
|
-
if (!videoRef || params.play !== 'on-hover')
|
|
116
|
-
return;
|
|
117
|
-
videoRef.pause();
|
|
118
|
-
}, loop: true, controls: params.controls, playsInline: true, className: `video video-${item.id}`, style: inlineStyles, children: (0, jsx_runtime_1.jsx)("source", { src: item.params.url }) }), (params.play === 'on-click' || params.play === 'on-hover') && item.params.coverUrl && !isVideoInteracted && ((0, jsx_runtime_1.jsx)("img", { onMouseEnter: () => {
|
|
120
|
+
}, children: [hasScrollPlayback && ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.params.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(params.play === 'on-click' || params.play === 'on-hover') && item.params.coverUrl && !isVideoInteracted && ((0, jsx_runtime_1.jsx)("img", { onMouseEnter: () => {
|
|
119
121
|
if (!videoRef || params.play !== 'on-hover')
|
|
120
122
|
return;
|
|
121
123
|
setIsVideoInteracted(true);
|
|
122
124
|
videoRef.play();
|
|
123
|
-
}, src: (
|
|
125
|
+
}, src: (_p = item.params.coverUrl) !== null && _p !== void 0 ? _p : '', className: `video-cover-${item.id}`, onClick: () => {
|
|
124
126
|
if (!videoRef)
|
|
125
127
|
return;
|
|
126
128
|
setIsVideoInteracted(true);
|