PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / lottie / save.js

save.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/blocks/lottie/save.js

63 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useBlockProps } from '@wordpress/block-editor';
2 import { applyFilters } from '@wordpress/hooks';
3
4 import metadata from './block.json';
5
6 const { name } = metadata;
7
8 /**
9 * Block Save Class.
10 *
11 * @param props
12 */
13 export default function BlockSave(props) {
14 const {
15 fileUrl,
16 fileWidth,
17 fileHeight,
18 trigger,
19 loop,
20 direction,
21 speed,
22 width,
23 } = props.attributes;
24
25 let className = 'ghostkit-lottie';
26
27 className = applyFilters('ghostkit.blocks.className', className, {
28 name,
29 ...props,
30 });
31
32 const blockProps = useBlockProps.save({
33 className,
34 'data-trigger': trigger,
35 style:
36 fileWidth && fileHeight
37 ? {
38 '--gkt-lottie__ar': `${fileWidth} / ${fileHeight}`,
39 '--gkt-lottie__width': width,
40 }
41 : {},
42 });
43
44 return (
45 <div {...blockProps}>
46 <lottie-player
47 src={fileUrl}
48 direction={direction}
49 background="transparent"
50 mode="normal"
51 {...(trigger !== 'scroll' ? { speed } : {})}
52 {...(trigger !== 'scroll' && loop ? { loop: 'loop' } : {})}
53 {...(!trigger ? { autoplay: 'autoplay' } : {})}
54 {...(trigger === 'hover' ? { hover: 'hover' } : {})}
55 style={{
56 width: '100%',
57 height: 'auto',
58 }}
59 />
60 </div>
61 );
62 }
63