@gem-sdk/components 2.0.0-dev.642 → 2.0.0-dev.644
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/cjs/icon-list-hoz/setting/IconListHoz.js +0 -5
- package/dist/cjs/icon-list-hoz/setting/configs/settings.js +1 -1
- package/dist/cjs/icon-list-hoz/setting/configs/uiV2.js +1 -1
- package/dist/cjs/third-party/components/SproutPlantTreesGrowSales.liquid.js +1 -1
- package/dist/cjs/video/components/HTML5Embed.js +1 -2
- package/dist/cjs/video/components/HTML5Embed.liquid.js +1 -2
- package/dist/cjs/video/components/LiteVimeoEmbed.js +5 -4
- package/dist/cjs/video/components/LiteVimeoEmbed.liquid.js +2 -1
- package/dist/cjs/video/components/common/common.js +11 -0
- package/dist/cjs/video/components/common/getAttr.js +2 -2
- package/dist/cjs/video/components/common/getClasses.js +2 -2
- package/dist/cjs/video/components/common/getStyle.js +3 -2
- package/dist/cjs/video/components/common/index.js +1 -1
- package/dist/cjs/video/hooks/useLiteVimeoEmbed.js +6 -1
- package/dist/esm/icon-list-hoz/setting/IconListHoz.js +0 -5
- package/dist/esm/icon-list-hoz/setting/configs/settings.js +1 -1
- package/dist/esm/icon-list-hoz/setting/configs/uiV2.js +1 -1
- package/dist/esm/third-party/components/SproutPlantTreesGrowSales.liquid.js +1 -1
- package/dist/esm/video/components/HTML5Embed.js +1 -2
- package/dist/esm/video/components/HTML5Embed.liquid.js +1 -2
- package/dist/esm/video/components/LiteVimeoEmbed.js +5 -4
- package/dist/esm/video/components/LiteVimeoEmbed.liquid.js +2 -1
- package/dist/esm/video/components/common/common.js +9 -0
- package/dist/esm/video/components/common/getAttr.js +2 -2
- package/dist/esm/video/components/common/getClasses.js +2 -2
- package/dist/esm/video/components/common/getStyle.js +3 -2
- package/dist/esm/video/components/common/index.js +1 -1
- package/dist/esm/video/hooks/useLiteVimeoEmbed.js +6 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ var thirdParty = require('../helpers/thirdParty.js');
|
|
|
6
6
|
|
|
7
7
|
const SproutPlantTreesGrowSales = ({ setting, advanced })=>{
|
|
8
8
|
const { align, appBlockId } = setting ?? {};
|
|
9
|
-
return thirdParty.getLiquidForAppBlock(appBlockId, align, advanced?.cssClass);
|
|
9
|
+
return thirdParty.getLiquidForAppBlock(appBlockId, align, `${advanced?.cssClass ?? ''}!gp-block`);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.default = SproutPlantTreesGrowSales;
|
|
@@ -19,7 +19,7 @@ const HTML5Embed = (props)=>{
|
|
|
19
19
|
const isInstantLP = mode !== 'edit';
|
|
20
20
|
const { thumbnail, muted, autoplay, loop, controls, src, style, title, className, lazy, preload } = props;
|
|
21
21
|
const { playVideoAndTurnOffThumbnail, videoRef, showThumbnail } = useLiteHtml5Embed.useLiteHtml5Embed(autoplay, src);
|
|
22
|
-
const preloadThumbnail = !isInstantLP && autoplay && thumbnail;
|
|
22
|
+
const preloadThumbnail = !isInstantLP && autoplay && muted && !!thumbnail;
|
|
23
23
|
const offLazyLoad = !lazy && props.isVideoComponent && isInstantLP;
|
|
24
24
|
const isMp4Video = index.listSourceVideoSupport.some((ext)=>src.endsWith(ext));
|
|
25
25
|
const hiddenRenderThumbnail = !thumbnail || !showThumbnail;
|
|
@@ -32,7 +32,6 @@ const HTML5Embed = (props)=>{
|
|
|
32
32
|
preloadThumbnail,
|
|
33
33
|
offLazyLoad,
|
|
34
34
|
src,
|
|
35
|
-
isInstantLP,
|
|
36
35
|
thumbnail
|
|
37
36
|
})
|
|
38
37
|
});
|
|
@@ -14,7 +14,7 @@ const HTML5Embed = (props)=>{
|
|
|
14
14
|
const videoId = `gp-video-${props.uid}`;
|
|
15
15
|
const isInstantLP = false;
|
|
16
16
|
const { thumbnail, muted, autoplay, loop, controls, src, style, title, className, lazy, preload } = props;
|
|
17
|
-
const preloadThumbnail = autoplay && thumbnail;
|
|
17
|
+
const preloadThumbnail = autoplay && muted && !!thumbnail;
|
|
18
18
|
const offLazyLoad = !lazy && props.isVideoComponent;
|
|
19
19
|
const isMp4Video = src.endsWith('.mp4');
|
|
20
20
|
const hiddenRenderThumbnail = !thumbnail || autoplay;
|
|
@@ -27,7 +27,6 @@ const HTML5Embed = (props)=>{
|
|
|
27
27
|
preloadThumbnail,
|
|
28
28
|
offLazyLoad,
|
|
29
29
|
src,
|
|
30
|
-
isInstantLP,
|
|
31
30
|
thumbnail
|
|
32
31
|
})
|
|
33
32
|
});
|
|
@@ -12,21 +12,22 @@ var index = require('./common/index.js');
|
|
|
12
12
|
var NextImage = require('../../image/components/NextImage.js');
|
|
13
13
|
|
|
14
14
|
const LiteVimeoEmbed = (props)=>{
|
|
15
|
-
const { title, lazy, aspectRatio } = props;
|
|
15
|
+
const { title, lazy, aspectRatio, autoplay, muted } = props;
|
|
16
16
|
const { iframeSrc, videoId } = index.getVimeoParams(props);
|
|
17
|
-
const
|
|
17
|
+
const preventAutoPlayByBrowser = autoplay && muted && !lazy;
|
|
18
|
+
const { addIframe, thumbnail, iframe, originRatio } = useLiteVimeoEmbed.useLiteVimeoEmbed(lazy, videoId);
|
|
18
19
|
const posterUrl = props.thumbnail || thumbnail;
|
|
19
20
|
const iframeVimeoStyle = system.createStyle({
|
|
20
21
|
...getStyle.getIframeVimeoStyle(aspectRatio)
|
|
21
22
|
});
|
|
22
23
|
const articleVimeoStyle = system.createStyle({
|
|
23
|
-
...getStyle.getArticleVimeoStyle(aspectRatio, posterUrl)
|
|
24
|
+
...getStyle.getArticleVimeoStyle(aspectRatio, posterUrl, originRatio)
|
|
24
25
|
});
|
|
25
26
|
const articleVimeoClasses = system.createClass({
|
|
26
27
|
...getClasses.getArticleVimeoClasses(posterUrl, aspectRatio)
|
|
27
28
|
});
|
|
28
29
|
const imageVimeoClasses = system.createClass({
|
|
29
|
-
...getClasses.getImageVimeoClasses(iframe)
|
|
30
|
+
...getClasses.getImageVimeoClasses(iframe, preventAutoPlayByBrowser)
|
|
30
31
|
});
|
|
31
32
|
const buttonVimeoClasses = system.createClass({
|
|
32
33
|
...getClasses.getButtonVimeoClasses(iframe)
|
|
@@ -13,6 +13,7 @@ var NextImage_liquid = require('../../image/components/NextImage.liquid.js');
|
|
|
13
13
|
const LiteVimeoEmbed = (props)=>{
|
|
14
14
|
const { title, id, lazy, aspectRatio, autoplay, muted, preload, thumbnailLink } = props;
|
|
15
15
|
const { iframeSrc } = index.getVimeoParams(props);
|
|
16
|
+
const preventAutoPlayByBrowser = autoplay && muted && !lazy;
|
|
16
17
|
const iframe = !lazy;
|
|
17
18
|
const posterUrl = props.thumbnail;
|
|
18
19
|
const stateVimeo = system.createStateOrContext({
|
|
@@ -35,7 +36,7 @@ const LiteVimeoEmbed = (props)=>{
|
|
|
35
36
|
...getClasses.getArticleVimeoClasses(posterUrl, aspectRatio)
|
|
36
37
|
});
|
|
37
38
|
const imageVimeoClasses = system.createClass({
|
|
38
|
-
...getClasses.getImageVimeoClasses(iframe)
|
|
39
|
+
...getClasses.getImageVimeoClasses(iframe, preventAutoPlayByBrowser)
|
|
39
40
|
});
|
|
40
41
|
const buttonVimeoClasses = system.createClass({
|
|
41
42
|
...getClasses.getButtonVimeoClasses(iframe)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const makeStyleResponsiveRatio = (name, value, originRatio)=>{
|
|
4
|
+
return {
|
|
5
|
+
[`--${name}`]: originRatio && value?.desktop === 'auto' ? originRatio : value?.desktop,
|
|
6
|
+
[`--${name}-tablet`]: originRatio && value?.tablet === 'auto' ? originRatio : value?.tablet,
|
|
7
|
+
[`--${name}-mobile`]: originRatio && value?.mobile === 'auto' ? originRatio : value?.mobile
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.makeStyleResponsiveRatio = makeStyleResponsiveRatio;
|
|
@@ -5,13 +5,13 @@ const getAttr = ({ uid })=>{
|
|
|
5
5
|
'data-id': uid
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
-
const getHtml5Attr = ({ videoId, title, autoplay, preloadThumbnail, offLazyLoad, src,
|
|
8
|
+
const getHtml5Attr = ({ videoId, title, autoplay, preloadThumbnail, offLazyLoad, src, thumbnail })=>{
|
|
9
9
|
return {
|
|
10
10
|
id: `${videoId}`,
|
|
11
11
|
title: `${title}`,
|
|
12
12
|
preload: `${autoplay && !preloadThumbnail || offLazyLoad ? 'metadata' : 'none'}`,
|
|
13
13
|
'data-src': `${src}`,
|
|
14
|
-
poster:
|
|
14
|
+
poster: preloadThumbnail && thumbnail ? thumbnail : '',
|
|
15
15
|
'data-poster': thumbnail || ''
|
|
16
16
|
};
|
|
17
17
|
};
|
|
@@ -71,9 +71,9 @@ const getVideoYoutubeClasses = (className, offLazyLoad)=>{
|
|
|
71
71
|
...composeClasses(classList)
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
const getImageVimeoClasses = (iframe)=>{
|
|
74
|
+
const getImageVimeoClasses = (iframe, preventAutoPlayByBrowser)=>{
|
|
75
75
|
let classList = `gp-h-full gp-w-full gp-relative gp-top-0 gp-left-0 gp-z-9`;
|
|
76
|
-
if (iframe) classList += ` gp-invisible gp-opacity-0`;
|
|
76
|
+
if (iframe && !preventAutoPlayByBrowser) classList += ` gp-invisible gp-opacity-0`;
|
|
77
77
|
return {
|
|
78
78
|
...composeClasses(classList)
|
|
79
79
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@gem-sdk/core');
|
|
4
|
+
var common = require('./common.js');
|
|
4
5
|
|
|
5
6
|
function filterTruthyStyles(styles) {
|
|
6
7
|
return Object.fromEntries(Object.entries(styles || {}).filter(([, value])=>!!value));
|
|
@@ -53,10 +54,10 @@ const getIframeVimeoStyle = (aspectRatio)=>{
|
|
|
53
54
|
};
|
|
54
55
|
return filterTruthyStyles(composeStyles);
|
|
55
56
|
};
|
|
56
|
-
const getArticleVimeoStyle = (aspectRatio, posterUrl)=>{
|
|
57
|
+
const getArticleVimeoStyle = (aspectRatio, posterUrl, originRatio)=>{
|
|
57
58
|
const composeStyles = {
|
|
58
59
|
backgroundImage: `url(${posterUrl})`,
|
|
59
|
-
...
|
|
60
|
+
...common.makeStyleResponsiveRatio('aspect', aspectRatio, originRatio)
|
|
60
61
|
};
|
|
61
62
|
return filterTruthyStyles(composeStyles);
|
|
62
63
|
};
|
|
@@ -52,7 +52,7 @@ const getYoutubeParams = (props)=>{
|
|
|
52
52
|
const getVimeoParams = (props)=>{
|
|
53
53
|
const { id, autoplay, muted, controls, loop, lazy } = props;
|
|
54
54
|
const videoId = encodeURIComponent(id);
|
|
55
|
-
const params = `?&autoplay=${lazy ? 1 : autoplay ? 1 : 0}` + `&muted=${muted ? 1 : 0}` + `&loop=${loop ? 1 : 0}` + `&controls=${controls}` +
|
|
55
|
+
const params = `?&autoplay=${lazy ? 1 : autoplay ? 1 : 0}` + `&muted=${muted ? 1 : 0}` + `&loop=${loop ? 1 : 0}` + `&controls=${controls}` + '&autopause=false';
|
|
56
56
|
const iframeSrc = `https://player.vimeo.com/video/${videoId}${params}`;
|
|
57
57
|
return {
|
|
58
58
|
videoId,
|
|
@@ -7,10 +7,14 @@ var React = require('react');
|
|
|
7
7
|
const useLiteVimeoEmbed = (lazy, videoId)=>{
|
|
8
8
|
const [thumbnail, setThumbnail] = React.useState();
|
|
9
9
|
const [iframe, setIframe] = React.useState(!lazy);
|
|
10
|
+
const [originRatio, setOriginRatio] = React.useState();
|
|
10
11
|
React.useEffect(()=>{
|
|
11
12
|
fetch(`https://vimeo.com/api/v2/video/${videoId}.json`).then((res)=>{
|
|
12
13
|
return res.json();
|
|
13
14
|
}).then(([video])=>{
|
|
15
|
+
if (video?.width && video?.height) {
|
|
16
|
+
setOriginRatio((video?.width / video?.height).toFixed(2));
|
|
17
|
+
}
|
|
14
18
|
setThumbnail(video?.thumbnail_large);
|
|
15
19
|
});
|
|
16
20
|
}, [
|
|
@@ -23,7 +27,8 @@ const useLiteVimeoEmbed = (lazy, videoId)=>{
|
|
|
23
27
|
return {
|
|
24
28
|
addIframe,
|
|
25
29
|
thumbnail,
|
|
26
|
-
iframe
|
|
30
|
+
iframe,
|
|
31
|
+
originRatio
|
|
27
32
|
};
|
|
28
33
|
};
|
|
29
34
|
|
|
@@ -2,7 +2,7 @@ import { getLiquidForAppBlock } from '../helpers/thirdParty.js';
|
|
|
2
2
|
|
|
3
3
|
const SproutPlantTreesGrowSales = ({ setting, advanced })=>{
|
|
4
4
|
const { align, appBlockId } = setting ?? {};
|
|
5
|
-
return getLiquidForAppBlock(appBlockId, align, advanced?.cssClass);
|
|
5
|
+
return getLiquidForAppBlock(appBlockId, align, `${advanced?.cssClass ?? ''}!gp-block`);
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export { SproutPlantTreesGrowSales as default };
|
|
@@ -15,7 +15,7 @@ const HTML5Embed = (props)=>{
|
|
|
15
15
|
const isInstantLP = mode !== 'edit';
|
|
16
16
|
const { thumbnail, muted, autoplay, loop, controls, src, style, title, className, lazy, preload } = props;
|
|
17
17
|
const { playVideoAndTurnOffThumbnail, videoRef, showThumbnail } = useLiteHtml5Embed(autoplay, src);
|
|
18
|
-
const preloadThumbnail = !isInstantLP && autoplay && thumbnail;
|
|
18
|
+
const preloadThumbnail = !isInstantLP && autoplay && muted && !!thumbnail;
|
|
19
19
|
const offLazyLoad = !lazy && props.isVideoComponent && isInstantLP;
|
|
20
20
|
const isMp4Video = listSourceVideoSupport.some((ext)=>src.endsWith(ext));
|
|
21
21
|
const hiddenRenderThumbnail = !thumbnail || !showThumbnail;
|
|
@@ -28,7 +28,6 @@ const HTML5Embed = (props)=>{
|
|
|
28
28
|
preloadThumbnail,
|
|
29
29
|
offLazyLoad,
|
|
30
30
|
src,
|
|
31
|
-
isInstantLP,
|
|
32
31
|
thumbnail
|
|
33
32
|
})
|
|
34
33
|
});
|
|
@@ -10,7 +10,7 @@ const HTML5Embed = (props)=>{
|
|
|
10
10
|
const videoId = `gp-video-${props.uid}`;
|
|
11
11
|
const isInstantLP = false;
|
|
12
12
|
const { thumbnail, muted, autoplay, loop, controls, src, style, title, className, lazy, preload } = props;
|
|
13
|
-
const preloadThumbnail = autoplay && thumbnail;
|
|
13
|
+
const preloadThumbnail = autoplay && muted && !!thumbnail;
|
|
14
14
|
const offLazyLoad = !lazy && props.isVideoComponent;
|
|
15
15
|
const isMp4Video = src.endsWith('.mp4');
|
|
16
16
|
const hiddenRenderThumbnail = !thumbnail || autoplay;
|
|
@@ -23,7 +23,6 @@ const HTML5Embed = (props)=>{
|
|
|
23
23
|
preloadThumbnail,
|
|
24
24
|
offLazyLoad,
|
|
25
25
|
src,
|
|
26
|
-
isInstantLP,
|
|
27
26
|
thumbnail
|
|
28
27
|
})
|
|
29
28
|
});
|
|
@@ -8,21 +8,22 @@ import { getVimeoParams } from './common/index.js';
|
|
|
8
8
|
import NextImage from '../../image/components/NextImage.js';
|
|
9
9
|
|
|
10
10
|
const LiteVimeoEmbed = (props)=>{
|
|
11
|
-
const { title, lazy, aspectRatio } = props;
|
|
11
|
+
const { title, lazy, aspectRatio, autoplay, muted } = props;
|
|
12
12
|
const { iframeSrc, videoId } = getVimeoParams(props);
|
|
13
|
-
const
|
|
13
|
+
const preventAutoPlayByBrowser = autoplay && muted && !lazy;
|
|
14
|
+
const { addIframe, thumbnail, iframe, originRatio } = useLiteVimeoEmbed(lazy, videoId);
|
|
14
15
|
const posterUrl = props.thumbnail || thumbnail;
|
|
15
16
|
const iframeVimeoStyle = createStyle({
|
|
16
17
|
...getIframeVimeoStyle(aspectRatio)
|
|
17
18
|
});
|
|
18
19
|
const articleVimeoStyle = createStyle({
|
|
19
|
-
...getArticleVimeoStyle(aspectRatio, posterUrl)
|
|
20
|
+
...getArticleVimeoStyle(aspectRatio, posterUrl, originRatio)
|
|
20
21
|
});
|
|
21
22
|
const articleVimeoClasses = createClass({
|
|
22
23
|
...getArticleVimeoClasses(posterUrl, aspectRatio)
|
|
23
24
|
});
|
|
24
25
|
const imageVimeoClasses = createClass({
|
|
25
|
-
...getImageVimeoClasses(iframe)
|
|
26
|
+
...getImageVimeoClasses(iframe, preventAutoPlayByBrowser)
|
|
26
27
|
});
|
|
27
28
|
const buttonVimeoClasses = createClass({
|
|
28
29
|
...getButtonVimeoClasses(iframe)
|
|
@@ -9,6 +9,7 @@ import NextImage from '../../image/components/NextImage.liquid.js';
|
|
|
9
9
|
const LiteVimeoEmbed = (props)=>{
|
|
10
10
|
const { title, id, lazy, aspectRatio, autoplay, muted, preload, thumbnailLink } = props;
|
|
11
11
|
const { iframeSrc } = getVimeoParams(props);
|
|
12
|
+
const preventAutoPlayByBrowser = autoplay && muted && !lazy;
|
|
12
13
|
const iframe = !lazy;
|
|
13
14
|
const posterUrl = props.thumbnail;
|
|
14
15
|
const stateVimeo = createStateOrContext({
|
|
@@ -31,7 +32,7 @@ const LiteVimeoEmbed = (props)=>{
|
|
|
31
32
|
...getArticleVimeoClasses(posterUrl, aspectRatio)
|
|
32
33
|
});
|
|
33
34
|
const imageVimeoClasses = createClass({
|
|
34
|
-
...getImageVimeoClasses(iframe)
|
|
35
|
+
...getImageVimeoClasses(iframe, preventAutoPlayByBrowser)
|
|
35
36
|
});
|
|
36
37
|
const buttonVimeoClasses = createClass({
|
|
37
38
|
...getButtonVimeoClasses(iframe)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const makeStyleResponsiveRatio = (name, value, originRatio)=>{
|
|
2
|
+
return {
|
|
3
|
+
[`--${name}`]: originRatio && value?.desktop === 'auto' ? originRatio : value?.desktop,
|
|
4
|
+
[`--${name}-tablet`]: originRatio && value?.tablet === 'auto' ? originRatio : value?.tablet,
|
|
5
|
+
[`--${name}-mobile`]: originRatio && value?.mobile === 'auto' ? originRatio : value?.mobile
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { makeStyleResponsiveRatio };
|
|
@@ -3,13 +3,13 @@ const getAttr = ({ uid })=>{
|
|
|
3
3
|
'data-id': uid
|
|
4
4
|
};
|
|
5
5
|
};
|
|
6
|
-
const getHtml5Attr = ({ videoId, title, autoplay, preloadThumbnail, offLazyLoad, src,
|
|
6
|
+
const getHtml5Attr = ({ videoId, title, autoplay, preloadThumbnail, offLazyLoad, src, thumbnail })=>{
|
|
7
7
|
return {
|
|
8
8
|
id: `${videoId}`,
|
|
9
9
|
title: `${title}`,
|
|
10
10
|
preload: `${autoplay && !preloadThumbnail || offLazyLoad ? 'metadata' : 'none'}`,
|
|
11
11
|
'data-src': `${src}`,
|
|
12
|
-
poster:
|
|
12
|
+
poster: preloadThumbnail && thumbnail ? thumbnail : '',
|
|
13
13
|
'data-poster': thumbnail || ''
|
|
14
14
|
};
|
|
15
15
|
};
|
|
@@ -69,9 +69,9 @@ const getVideoYoutubeClasses = (className, offLazyLoad)=>{
|
|
|
69
69
|
...composeClasses(classList)
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
-
const getImageVimeoClasses = (iframe)=>{
|
|
72
|
+
const getImageVimeoClasses = (iframe, preventAutoPlayByBrowser)=>{
|
|
73
73
|
let classList = `gp-h-full gp-w-full gp-relative gp-top-0 gp-left-0 gp-z-9`;
|
|
74
|
-
if (iframe) classList += ` gp-invisible gp-opacity-0`;
|
|
74
|
+
if (iframe && !preventAutoPlayByBrowser) classList += ` gp-invisible gp-opacity-0`;
|
|
75
75
|
return {
|
|
76
76
|
...composeClasses(classList)
|
|
77
77
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { makeStyleResponsive } from '@gem-sdk/core';
|
|
2
|
+
import { makeStyleResponsiveRatio } from './common.js';
|
|
2
3
|
|
|
3
4
|
function filterTruthyStyles(styles) {
|
|
4
5
|
return Object.fromEntries(Object.entries(styles || {}).filter(([, value])=>!!value));
|
|
@@ -51,10 +52,10 @@ const getIframeVimeoStyle = (aspectRatio)=>{
|
|
|
51
52
|
};
|
|
52
53
|
return filterTruthyStyles(composeStyles);
|
|
53
54
|
};
|
|
54
|
-
const getArticleVimeoStyle = (aspectRatio, posterUrl)=>{
|
|
55
|
+
const getArticleVimeoStyle = (aspectRatio, posterUrl, originRatio)=>{
|
|
55
56
|
const composeStyles = {
|
|
56
57
|
backgroundImage: `url(${posterUrl})`,
|
|
57
|
-
...
|
|
58
|
+
...makeStyleResponsiveRatio('aspect', aspectRatio, originRatio)
|
|
58
59
|
};
|
|
59
60
|
return filterTruthyStyles(composeStyles);
|
|
60
61
|
};
|
|
@@ -50,7 +50,7 @@ const getYoutubeParams = (props)=>{
|
|
|
50
50
|
const getVimeoParams = (props)=>{
|
|
51
51
|
const { id, autoplay, muted, controls, loop, lazy } = props;
|
|
52
52
|
const videoId = encodeURIComponent(id);
|
|
53
|
-
const params = `?&autoplay=${lazy ? 1 : autoplay ? 1 : 0}` + `&muted=${muted ? 1 : 0}` + `&loop=${loop ? 1 : 0}` + `&controls=${controls}` +
|
|
53
|
+
const params = `?&autoplay=${lazy ? 1 : autoplay ? 1 : 0}` + `&muted=${muted ? 1 : 0}` + `&loop=${loop ? 1 : 0}` + `&controls=${controls}` + '&autopause=false';
|
|
54
54
|
const iframeSrc = `https://player.vimeo.com/video/${videoId}${params}`;
|
|
55
55
|
return {
|
|
56
56
|
videoId,
|
|
@@ -3,10 +3,14 @@ import { useState, useEffect } from 'react';
|
|
|
3
3
|
const useLiteVimeoEmbed = (lazy, videoId)=>{
|
|
4
4
|
const [thumbnail, setThumbnail] = useState();
|
|
5
5
|
const [iframe, setIframe] = useState(!lazy);
|
|
6
|
+
const [originRatio, setOriginRatio] = useState();
|
|
6
7
|
useEffect(()=>{
|
|
7
8
|
fetch(`https://vimeo.com/api/v2/video/${videoId}.json`).then((res)=>{
|
|
8
9
|
return res.json();
|
|
9
10
|
}).then(([video])=>{
|
|
11
|
+
if (video?.width && video?.height) {
|
|
12
|
+
setOriginRatio((video?.width / video?.height).toFixed(2));
|
|
13
|
+
}
|
|
10
14
|
setThumbnail(video?.thumbnail_large);
|
|
11
15
|
});
|
|
12
16
|
}, [
|
|
@@ -19,7 +23,8 @@ const useLiteVimeoEmbed = (lazy, videoId)=>{
|
|
|
19
23
|
return {
|
|
20
24
|
addIframe,
|
|
21
25
|
thumbnail,
|
|
22
|
-
iframe
|
|
26
|
+
iframe,
|
|
27
|
+
originRatio
|
|
23
28
|
};
|
|
24
29
|
};
|
|
25
30
|
|