pb-sxp-ui 1.0.18 → 1.0.19
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 +28 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -21
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +28 -21
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +1 -1
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/PictureGroup/Picture.js +23 -19
- package/es/core/components/SxpPageRender/PictureGroup/index.js +5 -2
- package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +22 -18
- package/lib/core/components/SxpPageRender/PictureGroup/index.js +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -12237,24 +12237,19 @@ const FingerSwipeTip = ({ imageUrl }) => {
|
|
12237
12237
|
* @Author: binruan@chatlabs.com
|
12238
12238
|
* @Date: 2024-03-20 10:27:31
|
12239
12239
|
* @LastEditors: binruan@chatlabs.com
|
12240
|
-
* @LastEditTime: 2024-04-17
|
12240
|
+
* @LastEditTime: 2024-04-17 15:37:47
|
12241
12241
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\Picture.tsx
|
12242
12242
|
*
|
12243
12243
|
*/
|
12244
12244
|
const Picture = (props) => {
|
12245
12245
|
const { src, height, width } = props;
|
12246
12246
|
const [blur, setBlur] = React.useState(false);
|
12247
|
-
const imgDom = React.useRef(null);
|
12248
12247
|
const { sxpParameter } = useSxpDataSource();
|
12249
|
-
const getAvifToPng = React.useCallback((src) => {
|
12250
|
-
return src.indexOf('avif') !== -1 ? `${src}?imageMogr2/format/webp` : src;
|
12251
|
-
}, []);
|
12252
12248
|
React.useEffect(() => {
|
12253
|
-
if (
|
12249
|
+
if (src === '' || !src)
|
12254
12250
|
return;
|
12255
|
-
}
|
12256
12251
|
const img = new Image();
|
12257
|
-
img.src = src
|
12252
|
+
img.src = `${src}?imageMogr2/format/jpg`;
|
12258
12253
|
img.onload = () => {
|
12259
12254
|
const aspectRatio = img.height / img.width;
|
12260
12255
|
const targetAspectRatio = 16 / 9;
|
@@ -12263,22 +12258,31 @@ const Picture = (props) => {
|
|
12263
12258
|
setBlur(true);
|
12264
12259
|
}
|
12265
12260
|
};
|
12266
|
-
|
12267
|
-
|
12261
|
+
}, [src]);
|
12262
|
+
const getImg = React.useCallback((src, style) => {
|
12263
|
+
if (src === '' || !src)
|
12264
|
+
return;
|
12265
|
+
return (React.createElement("picture", null,
|
12266
|
+
React.createElement("source", { type: 'image/avif', srcSet: `${src}?imageMogr2/format/avif` }),
|
12267
|
+
React.createElement("source", { type: 'image/webp', srcSet: `${src}?imageMogr2/format/webp` }),
|
12268
|
+
React.createElement("source", { type: 'image/jpeg', srcSet: `${src}?imageMogr2/format/jpg` }),
|
12269
|
+
React.createElement("img", { loading: 'lazy', src: src, style: style })));
|
12270
|
+
}, []);
|
12268
12271
|
return (React.createElement("div", { style: {
|
12269
12272
|
overflow: 'hidden',
|
12270
12273
|
height,
|
12271
12274
|
width: '100%',
|
12272
12275
|
position: 'relative'
|
12273
12276
|
} },
|
12274
|
-
|
12275
|
-
|
12276
|
-
|
12277
|
-
|
12278
|
-
|
12279
|
-
|
12280
|
-
|
12281
|
-
blur &&
|
12277
|
+
getImg(src !== null && src !== void 0 ? src : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image, {
|
12278
|
+
height: '100%',
|
12279
|
+
width: '100%',
|
12280
|
+
objectFit: 'cover',
|
12281
|
+
filter: blur ? 'blur(10px)' : 'none',
|
12282
|
+
transform: blur ? 'scale(1.2)' : 'none'
|
12283
|
+
}),
|
12284
|
+
blur &&
|
12285
|
+
getImg(src, {
|
12282
12286
|
width: '100%',
|
12283
12287
|
objectFit: 'contain',
|
12284
12288
|
position: 'absolute',
|
@@ -12286,22 +12290,24 @@ const Picture = (props) => {
|
|
12286
12290
|
transform: 'translateY(-50%)',
|
12287
12291
|
left: 0,
|
12288
12292
|
right: 0
|
12289
|
-
}
|
12293
|
+
})));
|
12290
12294
|
};
|
12291
12295
|
|
12292
12296
|
/*
|
12293
12297
|
* @Author: lewinlu@chatlabs.com
|
12294
12298
|
* @Date: 2024-01-03 14:39:09
|
12295
12299
|
* @LastEditors: binruan@chatlabs.com
|
12296
|
-
* @LastEditTime: 2024-04-17
|
12300
|
+
* @LastEditTime: 2024-04-17 15:15:33
|
12297
12301
|
* @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\PictureGroup\index.tsx
|
12298
12302
|
*/
|
12299
12303
|
const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd, onViewImageStartEvent }) => {
|
12304
|
+
const ref = React.useRef();
|
12300
12305
|
const { isActive } = useSwiperSlide();
|
12301
12306
|
const { sxpParameter, openHashtag } = useSxpDataSource();
|
12302
12307
|
const [isLoad, setIsLoad] = React.useState(false);
|
12303
12308
|
React.useEffect(() => {
|
12304
12309
|
if (isLoad && isActive) {
|
12310
|
+
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.start();
|
12305
12311
|
if (openHashtag) {
|
12306
12312
|
onReportViewImageEnd(rec);
|
12307
12313
|
}
|
@@ -12311,12 +12317,13 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onReportViewImageEnd
|
|
12311
12317
|
}
|
12312
12318
|
else {
|
12313
12319
|
setIsLoad(true);
|
12320
|
+
(ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
|
12314
12321
|
}
|
12315
12322
|
}, [rec, isActive, onReportViewImageEnd, openHashtag, index, onViewImageStartEvent, isLoad]);
|
12316
12323
|
// if (!isActive) {
|
12317
12324
|
// return <img src={sxpParameter?.placeholder_image} style={{ width, height, objectFit: 'cover' }} />;
|
12318
12325
|
// }
|
12319
|
-
return (React.createElement(Swiper, { defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay:
|
12326
|
+
return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: { clickable: true, bulletActiveClass: 'swipe-item-active-bullet' }, height: height, loop: true, autoplay: { delay: 3000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url) => {
|
12320
12327
|
return (React.createElement(SwiperSlide, { key: url },
|
12321
12328
|
React.createElement(Picture, { src: url, width: width, height: height })));
|
12322
12329
|
})));
|