PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / controls / gsap-animation.php

gsap-animation.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.0, at includes/controls/gsap-animation.php

140 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Controls;
3
4 use ABlocks\Classes\ControlBaseAbstract;
5
6 class GsapAnimation extends ControlBaseAbstract {
7 public static function get_attribute_default_value( $is_responsive = false ) {
8 if ( $is_responsive ) {
9 return [
10 'animationType' => 'none',
11 'duration' => 1,
12 'delay' => 0,
13 'triggerType' => 'scroll',
14 // from method values
15 'ease' => 'none',
16 'x' => 0,
17 'y' => 0,
18 'rotation' => 0,
19 'rotationY' => 0,
20 'opacity' => 1,
21 // to method values
22 'xTo' => 0,
23 'yTo' => 0,
24 'rotationTo' => 0,
25 'rotationYTo' => 0,
26 'opacityTo' => 1,
27 'easeTo' => 'none',
28 // repeat/loops
29 'loops' => false,
30 'numberOfRepeat' => 0, // if -1 then infinite loops
31 'isSmooth' => true, // yoyo
32 // if animation type 'scroll' then these will work
33 'startPoint' => 80, // top ${this.attribute?.startPoint ?? 80}%
34 'endPoint' => 10
35 ];
36
37 }//end if
38 return [
39 'animationType' => 'none',
40 'duration' => 1,
41 'delay' => 0,
42 'triggerType' => 'scroll',
43 // from method values
44 'ease' => 'none',
45 'x' => 0,
46 'y' => 0,
47 'rotation' => 0,
48 'rotationY' => 0,
49 'opacity' => 1,
50 // to method values
51 'xTo' => 0,
52 'yTo' => 0,
53 'rotationTo' => 0,
54 'rotationYTo' => 0,
55 'opacityTo' => 1,
56 'easeTo' => 'none',
57 // repeat/loops
58 'loops' => false,
59 'numberOfRepeat' => 0, // if -1 then infinite loops
60 'isSmooth' => true, // yoyo
61 // if animation type 'scroll' then these will work
62 'startPoint' => 80, // top ${this.attribute?.startPoint ?? 80}%
63 'endPoint' => 10
64 ];
65 }
66
67 public static function get_attribute( $attributeName, $isResponsive = false ) {
68 return [
69 $attributeName => [
70 'type' => 'object',
71 'default' => self::get_attribute_default_value( $isResponsive ),
72 ]
73 ];
74 }
75
76 public static function get_css( $attribute_value, $property = '', $device = '' ) {
77 $default_attar_value = self::get_attribute_default_value( (bool) $device );
78 $value = wp_parse_args( $attribute_value, $default_attar_value );
79
80 $css = [];
81
82 /**
83 * Generated CSS
84 * css property
85 * mask-image
86 * mask-size
87 * mask-position
88 * mask-repeat
89 */
90
91 if ( $value['mask'] ) {
92 if ( 'custom' === $value['maskShape'] ) {
93 $css['mask-image'] = 'url(' . $value['customMaskShape'] . ')';
94 } else {
95 $css['mask-image'] = 'url(' . ABLOCKS_ROOT_URL . '/assets/images/mask-shapes/' . $value['maskShape'] . '.svg)';
96 }
97 $css['mask-size'] = 'contain';
98 $css['mask-position'] = 'center center';
99 $css['mask-repeat'] = 'no-repeat';
100 }
101
102 if ( $value[ 'maskSize' . $device ] && 'custom' !== $value[ 'maskSize' . $device ] ) {
103 $css['mask-size'] = $value[ 'maskSize' . $device ];
104 }
105
106 if (
107 $value[ 'maskSize' . $device ] &&
108 'custom' === $value[ 'maskSize' . $device ] &&
109 $value[ 'scaleUnit' . $device ]
110 ) {
111 $css['mask-size'] = $value[ 'scale' . $device ] . $value[ 'scaleUnit' . $device ];
112 }
113
114 if (
115 'custom' === $value[ 'maskPosition' . $device ] &&
116 $value[ 'xPosition' . $device ] &&
117 $value[ 'xPositionUnit' . $device ]
118 ) {
119 $css['-webkit-mask-position-x'] = $value[ 'xPosition' . $device ] . $value[ 'xPositionUnit' . $device ];
120 $css['-webkit-mask-position-y'] = $value[ 'yPosition' . $device ] . $value[ 'yPositionUnit' . $device ];
121 }
122
123 if (
124 'custom' === $value[ 'maskPosition' . $device ] &&
125 $value[ 'yPosition' . $device ] &&
126 $value[ 'yPositionUnit' . $device ]
127 ) {
128 $css['-webkit-mask-position-y'] = $value[ 'yPosition' . $device ] . $value[ 'yPositionUnit' . $device ];
129 }
130
131 if ( $value[ 'maskRepeat' . $device ] ) {
132 $css['mask-repeat'] = $value[ 'maskRepeat' . $device ];
133 }
134
135 return [];
136 }
137
138
139 }
140