pb-sxp-ui 1.0.25 → 1.0.26
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.cjs +42 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -14
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +42 -14
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/FormatImage.js +7 -6
- package/es/core/components/SxpPageRender/VideoWidget/index.js +35 -8
- package/lib/core/components/SxpPageRender/FormatImage.js +6 -5
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +35 -8
- package/package.json +1 -1
package/dist/pb-ui.js
CHANGED
@@ -8303,21 +8303,22 @@
|
|
8303
8303
|
* @Author: binruan@chatlabs.com
|
8304
8304
|
* @Date: 2024-03-20 10:27:31
|
8305
8305
|
* @LastEditors: binruan@chatlabs.com
|
8306
|
-
* @LastEditTime: 2024-04-
|
8306
|
+
* @LastEditTime: 2024-04-19 14:12:55
|
8307
8307
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
|
8308
8308
|
*
|
8309
8309
|
*/
|
8310
8310
|
const FormatImage = React.forwardRef((props, ref) => {
|
8311
8311
|
const { src, onLoad, style, className, loading } = props;
|
8312
|
-
const [imgSrc, setImgSrc] = React.useState(
|
8312
|
+
const [imgSrc, setImgSrc] = React.useState();
|
8313
8313
|
React.useImperativeHandle(ref, () => ({
|
8314
8314
|
setSrc: (v) => {
|
8315
8315
|
setImgSrc(v);
|
8316
8316
|
}
|
8317
8317
|
}));
|
8318
|
-
|
8319
|
-
|
8320
|
-
|
8318
|
+
React.useEffect(() => {
|
8319
|
+
setImgSrc(src);
|
8320
|
+
}, [src]);
|
8321
|
+
return (React.createElement(React.Fragment, null, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
|
8321
8322
|
React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
|
8322
8323
|
React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
|
8323
8324
|
React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
|
@@ -8325,7 +8326,7 @@
|
|
8325
8326
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
|
8326
8327
|
} }))) : (React.createElement("img", { className: className, src: imgSrc, style: style, loading: loading, onLoad: (e) => {
|
8327
8328
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(e.target);
|
8328
|
-
} }));
|
8329
|
+
} }))));
|
8329
8330
|
});
|
8330
8331
|
var FormatImage$1 = React.memo(FormatImage);
|
8331
8332
|
|
@@ -11989,6 +11990,8 @@ Made in Italy` })));
|
|
11989
11990
|
const [isLoadFinish, setIsLoadFinish] = React.useState(false);
|
11990
11991
|
const [isFirstPlay, setIsFirstPlay] = React.useState(true);
|
11991
11992
|
const { isActive } = useSwiperSlide();
|
11993
|
+
const canvasRef = React.useRef(null);
|
11994
|
+
const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
|
11992
11995
|
React.useEffect(() => {
|
11993
11996
|
if (!videoRef.current)
|
11994
11997
|
return;
|
@@ -12082,8 +12085,24 @@ Made in Italy` })));
|
|
12082
12085
|
});
|
12083
12086
|
}
|
12084
12087
|
}, [data, index, bffEventReport]);
|
12088
|
+
const handLoadeddata = React.useCallback(() => {
|
12089
|
+
const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
|
12090
|
+
if (!video)
|
12091
|
+
return;
|
12092
|
+
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
12093
|
+
if (!canvas)
|
12094
|
+
return;
|
12095
|
+
const ctx = canvas.getContext('2d');
|
12096
|
+
const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
|
12097
|
+
const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
|
12098
|
+
canvas.height = targetHeight;
|
12099
|
+
canvas.width = targetWidth;
|
12100
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
12101
|
+
setFirstFrameSrc(canvas.toDataURL());
|
12102
|
+
canvas.remove();
|
12103
|
+
}, []);
|
12085
12104
|
React.useEffect(() => {
|
12086
|
-
var _a, _b;
|
12105
|
+
var _a, _b, _c;
|
12087
12106
|
if (!videoRef.current)
|
12088
12107
|
return;
|
12089
12108
|
setIsPauseVideo(false);
|
@@ -12108,12 +12127,14 @@ Made in Italy` })));
|
|
12108
12127
|
}
|
12109
12128
|
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', handleLoadedMetadata);
|
12110
12129
|
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('playing', handlePlaying);
|
12130
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('loadeddata', handLoadeddata);
|
12111
12131
|
return () => {
|
12112
|
-
var _a, _b;
|
12132
|
+
var _a, _b, _c;
|
12113
12133
|
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', handleLoadedMetadata);
|
12114
12134
|
(_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('playing', handlePlaying);
|
12135
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('loadeddata', handLoadeddata);
|
12115
12136
|
};
|
12116
|
-
}, [handleLoadedMetadata, handlePlaying, rec.video]);
|
12137
|
+
}, [handleLoadedMetadata, handlePlaying, rec.video, handLoadeddata]);
|
12117
12138
|
React.useEffect(() => {
|
12118
12139
|
var _a;
|
12119
12140
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
@@ -12179,21 +12200,27 @@ Made in Italy` })));
|
|
12179
12200
|
? `translateY(-${50 + ((_a = videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.offsetTop) !== null && _a !== void 0 ? _a : 0)}%)`
|
12180
12201
|
: 'translateY(-50%)';
|
12181
12202
|
}, [videoPostConfig]);
|
12203
|
+
const blurBgSrc = React.useMemo(() => {
|
12204
|
+
var _a;
|
12205
|
+
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
12206
|
+
}, [firstFrameSrc, rec]);
|
12182
12207
|
if (!rec.video) {
|
12183
12208
|
return null;
|
12184
12209
|
}
|
12185
12210
|
return (React.createElement(React.Fragment, null, blur ? (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
|
12186
12211
|
position: 'relative',
|
12187
12212
|
width: '100%',
|
12188
|
-
height
|
12213
|
+
height,
|
12214
|
+
overflow: 'hidden'
|
12189
12215
|
} },
|
12190
|
-
React.createElement(FormatImage$1, { src:
|
12216
|
+
React.createElement(FormatImage$1, { src: blurBgSrc, style: {
|
12191
12217
|
height: '100%',
|
12192
12218
|
width: '100%',
|
12193
12219
|
objectFit: 'cover',
|
12194
12220
|
filter: blur ? 'blur(10px)' : 'none',
|
12195
12221
|
transform: blur ? 'scale(1.2)' : 'none'
|
12196
12222
|
} }),
|
12223
|
+
React.createElement("canvas", { ref: canvasRef, style: { display: 'none' } }),
|
12197
12224
|
React.createElement("div", { style: {
|
12198
12225
|
position: 'absolute',
|
12199
12226
|
width: '100%',
|
@@ -12204,7 +12231,7 @@ Made in Italy` })));
|
|
12204
12231
|
right: 0
|
12205
12232
|
} },
|
12206
12233
|
React.createElement("div", { style: { position: 'relative' } },
|
12207
|
-
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
|
12234
|
+
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
|
12208
12235
|
width: '100%',
|
12209
12236
|
height: 'auto',
|
12210
12237
|
objectFit: 'contain'
|
@@ -12213,9 +12240,10 @@ Made in Italy` })));
|
|
12213
12240
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))))) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
|
12214
12241
|
position: 'relative',
|
12215
12242
|
width: '100%',
|
12216
|
-
height
|
12243
|
+
height,
|
12244
|
+
overflow: 'hidden'
|
12217
12245
|
} },
|
12218
|
-
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
|
12246
|
+
React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', poster: sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
|
12219
12247
|
renderPoster,
|
12220
12248
|
React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
|
12221
12249
|
};
|