PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.1.0
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.1.0
4.11.79 4.11.78 4.11.77 4.11.76 4.11.75 3.20.5 4.11.69 3.20.6 4.11.7 3.20.7 4.11.70 3.20.8 4.11.71 3.20.9 4.11.72 3.21.1 4.11.73 3.21.2 4.11.74 3.21.3 4.11.8 3.21.4 4.11.9 3.21.5 4.2.0 3.21.6 4.2.1 3.3.0 4.2.2 3.3.1 4.2.3 3.3.2 4.2.4 3.3.3 4.2.5 3.3.4 4.2.6 3.3.5 4.2.7 3.3.6 4.2.8 3.3.7 4.2.9 3.3.8 4.3.0 3.3.9 4.3.1 3.4.0 4.3.2 3.4.1 4.3.3 3.4.2 4.3.4 3.4.3 4.3.5 3.4.4 4.3.6 3.4.5 4.3.7 3.4.6 4.3.8 3.4.7 4.3.9 3.4.8 4.4.0 3.4.9 4.4.1 3.5.0 4.4.2 3.5.1 4.4.3 3.5.2 4.4.4 3.5.3 4.4.5 3.5.4 4.4.6 3.5.5 4.4.7 3.5.6 4.4.8 3.5.7 4.4.9 3.5.8 4.5.0 3.5.9 4.5.1 3.6.0 4.5.2 3.6.1 4.5.3 3.6.2 4.5.4 3.6.3 4.5.5 3.6.4 4.5.6 3.6.5 4.5.7 3.6.6 4.5.8 3.6.7 4.5.9 3.6.8 4.6.0 3.6.9 4.6.1 3.7.0 4.7.0 3.7.1 4.7.1 3.7.2 4.7.2 3.7.3 4.7.3 3.7.4 4.7.4 3.7.5 4.7.5 3.7.6 4.7.6 3.7.7 4.7.7 3.7.8 4.7.8 3.7.9 4.7.9 3.8.0 4.8.0 3.8.1 4.8.1 3.8.2 4.8.10 3.8.3 4.8.11 3.8.4 4.8.2 3.8.5 4.8.3 3.8.6 4.8.4 3.8.7 4.8.5 3.8.8 4.8.6 3.8.9 4.8.7 3.9.0 4.8.8 3.9.1 4.8.9 3.9.2 4.9.0 3.9.3 4.9.0-beta1 3.9.4 4.9.0-beta2 3.9.5 4.9.1 3.9.6 4.9.10 3.9.7 4.9.11 3.9.8 4.9.12 3.9.9 4.9.13 4.0.1 4.9.14 4.0.3 4.9.15 4.0.4 4.9.16 4.0.5 4.9.17 4.0.6 4.9.18 4.0.7 4.9.19 4.0.8 4.9.2 4.0.9 4.9.20 4.1.0 4.9.21 4.1.1 4.9.22 4.1.2 4.9.23 4.1.3 4.9.24 trunk 4.1.4 4.9.25 1.0 4.1.5 4.9.26 1.01 4.1.6 4.9.27 1.02 4.1.7 4.9.28 1.03 4.1.8 4.9.29 1.04 4.1.9 4.9.3 1.05 4.10.0 4.9.30 1.06 4.10.1 4.9.31 1.07 4.10.10 4.9.32 1.08 4.10.11 4.9.33 1.09 4.10.12 4.9.34 2.0 4.10.13 4.9.35 2.0.1 4.10.14 4.9.36 2.0.2 4.10.15 4.9.37 2.0.3 4.10.16 4.9.38 2.0.4 4.10.17 4.9.39 2.0.5 4.10.18 4.9.4 2.0.6 4.10.19 4.9.40 2.0.7 4.10.2 4.9.41 2.0.8 4.10.20 4.9.42 2.0.9 4.10.21 4.9.43 2.1.0 4.10.22 4.9.45 2.1.1 4.10.23 4.9.46 2.1.2 4.10.24 4.9.47 2.1.3 4.10.25 4.9.48 2.1.4 4.10.26 4.9.49 2.1.5 4.10.27 4.9.5 2.1.5-beta1 4.10.28 4.9.50 2.1.6 4.10.29 4.9.51 2.1.7 4.10.3 4.9.52 2.1.8 4.10.30 4.9.53 2.1.9 4.10.31 4.9.54 2.2.0 4.10.32 4.9.55 2.2.1 4.10.33 4.9.56 2.2.2 4.10.34 4.9.57 2.2.3 4.10.35 4.9.6 2.2.4 4.10.36 4.9.7 2.2.5 4.10.37 4.9.8 2.2.6 4.10.38 4.9.9 2.2.7 4.10.39 2.2.8 4.10.4 2.2.9 4.10.40 2.3.0 4.10.41 2.3.1 4.10.42 2.3.2 4.10.43 2.3.3 4.10.44 2.3.4 4.10.45 2.3.5 4.10.46 2.3.6 4.10.47 2.3.7 4.10.48 2.3.8 4.10.49 2.3.9 4.10.5 2.4.0 4.10.50 2.4.1 4.10.51 2.5.0 4.10.52 2.5.1 4.10.53 2.5.2 4.10.54 2.5.3 4.10.55 2.5.4 4.10.56 2.5.5 4.10.57 2.5.6 4.10.58 2.5.7 4.10.59 2.5.8 4.10.6 2.5.9 4.10.60 2.6.0 4.10.61 2.6.1 4.10.62 2.6.2 4.10.63 2.6.3 4.10.64 2.6.4 4.10.65 2.6.5 4.10.66 2.6.6 4.10.67 2.6.7 4.10.68 2.6.8 4.10.69 2.6.9 4.10.7 2.7.0 4.10.70 2.7.1 4.10.71 2.7.2 4.10.72 2.7.3 4.10.73 2.7.4 4.10.74 2.7.5 4.10.75 2.7.6 4.10.76 2.7.7 4.10.77 2.7.8 4.10.78 2.7.9 4.10.79 2.8.0 4.10.8 2.8.1 4.10.80 2.8.2 4.10.81 2.8.3 4.10.82 2.8.4 4.10.83 2.8.5 4.10.84 2.8.6 4.10.85 2.8.7 4.10.86 2.8.8 4.10.87 2.8.9 4.10.88 2.9.0 4.10.89 2.9.1 4.10.9 2.9.2 4.10.90 2.9.3 4.11.0 2.9.4 4.11.1 2.9.5 4.11.10 2.9.6 4.11.11 2.9.7 4.11.12 2.9.8 4.11.13 2.9.9 4.11.14 3.0.0 4.11.15 3.0.1 4.11.16 3.0.2 4.11.17 3.0.3 4.11.18 3.0.4 4.11.19 3.0.5 4.11.2 3.0.6 4.11.20 3.0.7 4.11.21 3.0.8 4.11.22 3.0.9 4.11.23 3.1.0 4.11.24 3.1.1 4.11.25 3.1.2 4.11.26 3.1.3 4.11.27 3.1.4 4.11.28 3.1.5 4.11.29 3.1.6 4.11.3 3.1.7 4.11.30 3.1.8 4.11.31 3.1.9 4.11.32 3.10.0 4.11.33 3.10.1 4.11.34 3.10.2 4.11.35 3.10.3 4.11.36 3.10.4 4.11.37 3.10.5 4.11.38 3.10.6 4.11.39 3.10.7 4.11.4 3.10.8 4.11.40 3.10.9 4.11.41 3.11.0 4.11.42 3.11.1 4.11.43 3.11.2 4.11.44 3.11.3 4.11.45 3.11.4 4.11.46 3.11.5 4.11.47 3.11.6 4.11.48 3.11.7 4.11.49 3.11.8 4.11.5 3.11.9 4.11.50 3.12.0 4.11.51 3.12.1 4.11.52 3.12.2 4.11.53 3.12.3 4.11.54 3.2.0 4.11.55 3.2.1 4.11.56 3.2.2 4.11.57 3.2.3 4.11.58 3.2.4 4.11.59 3.2.5 4.11.6 3.2.6 4.11.60 3.2.7 4.11.61 3.2.8 4.11.62 3.2.9 4.11.63 3.20.0 4.11.64 3.20.1 4.11.65 3.20.2 4.11.66 3.20.3 4.11.67 3.20.4 4.11.68
premium-addons-for-elementor / widgets / premium-lottie.php
premium-addons-for-elementor / widgets Last commit date
dep 5 years ago premium-banner.php 5 years ago premium-blog.php 5 years ago premium-button.php 5 years ago premium-carousel.php 5 years ago premium-contactform.php 5 years ago premium-countdown.php 5 years ago premium-counter.php 5 years ago premium-dual-header.php 5 years ago premium-fancytext.php 5 years ago premium-grid.php 5 years ago premium-icon-list.php 5 years ago premium-image-button.php 5 years ago premium-image-scroll.php 5 years ago premium-image-separator.php 5 years ago premium-lottie.php 5 years ago premium-maps.php 5 years ago premium-modalbox.php 5 years ago premium-person.php 5 years ago premium-pricing-table.php 5 years ago premium-progressbar.php 5 years ago premium-testimonials.php 5 years ago premium-title.php 5 years ago premium-videobox.php 5 years ago premium-vscroll.php 5 years ago
premium-lottie.php
702 lines
1 <?php
2
3 /**
4 * Premium Lottie Animations.
5 */
6 namespace PremiumAddons\Widgets;
7
8 // Elementor Classes.
9 use Elementor\Widget_Base;
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Border;
12 use Elementor\Group_Control_Css_Filter;
13 use Elementor\Group_Control_Box_Shadow;
14
15 // PremiumAddons Classes.
16 use PremiumAddons\Includes\Helper_Functions;
17 use PremiumAddons\Includes\Premium_Template_Tags;
18
19 if ( ! defined( 'ABSPATH' ) ) exit; // If this file is called directly, abort.
20
21 /**
22 * Class Premium_Lottie
23 */
24 class Premium_Lottie extends Widget_Base {
25
26 public function get_name() {
27 return 'premium-lottie';
28 }
29
30 public function getTemplateInstance() {
31 return $this->templateInstance = Premium_Template_Tags::getInstance();
32 }
33
34 public function get_style_depends() {
35 return [
36 'premium-addons'
37 ];
38 }
39
40 public function get_script_depends() {
41 return [
42 'lottie-js'
43 ];
44 }
45
46 public function get_title() {
47 return sprintf( '%1$s %2$s', Helper_Functions::get_prefix(), __('Lottie Animations', 'premium-addons-for-elementor') );
48 }
49
50 public function get_icon() {
51 return 'pa-lottie-animations';
52 }
53
54 public function get_categories() {
55 return [ 'premium-elements' ];
56 }
57
58 public function get_custom_help_url() {
59 return 'https://premiumaddons.com/support/';
60 }
61
62 /**
63 * Register Testimonials controls.
64 *
65 * @since 3.20.0
66 * @access protected
67 */
68 protected function _register_controls() {
69
70 $this->start_controls_section('section_general_settings',
71 [
72 'label' => __('General Settings', 'premium-addons-for-elementor'),
73 ]
74 );
75
76 $this->add_control('source',
77 [
78 'label' => __('File Source', 'premium-addons-pro'),
79 'type' => Controls_Manager::SELECT,
80 'options' => [
81 'url' => __('External URL','premium-addons-pro'),
82 'file' => __('Media File', 'premium-addons-pro')
83 ],
84 'default' => 'url'
85 ]
86 );
87
88 $this->add_control('lottie_url',
89 [
90 'label' => __( 'Animation JSON URL', 'premium-addons-for-elementor' ),
91 'type' => Controls_Manager::TEXT,
92 'dynamic' => [ 'active' => true ],
93 'description' => 'Get JSON code URL from <a href="https://lottiefiles.com/" target="_blank">here</a>',
94 'label_block' => true,
95 'condition' => [
96 'source' => 'url'
97 ]
98 ]
99 );
100
101 $this->add_control('lottie_file',
102 [
103 'label' => __( 'Upload JSON File', 'premium-addons-for-elementor' ),
104 'type' => Controls_Manager::MEDIA,
105 'media_type'=> 'application/json',
106 'frontend_available' => true,
107 'condition' => [
108 'source' => 'file',
109 ],
110 ]
111 );
112
113 $this->add_control('lottie_loop',
114 [
115 'label' => __('Loop','premium-addons-for-elementor'),
116 'type' => Controls_Manager::SWITCHER,
117 'return_value' => 'true',
118 'default' => 'true',
119 ]
120 );
121
122 $this->add_control('lottie_reverse',
123 [
124 'label' => __('Reverse','premium-addons-for-elementor'),
125 'type' => Controls_Manager::SWITCHER,
126 'return_value' => 'true',
127 ]
128 );
129
130 $this->add_control('lottie_speed',
131 [
132 'label' => __( 'Animation Speed', 'premium-addons-for-elementor' ),
133 'type' => Controls_Manager::NUMBER,
134 'default' => 1,
135 'min' => 0.1,
136 'max' => 3,
137 'step' => 0.1
138 ]
139 );
140
141 $this->add_control('trigger',
142 [
143 'label' => __( 'Trigger', 'premium-addons-for-elementor' ),
144 'type' => Controls_Manager::SELECT,
145 'options' => [
146 'none' => __( 'None', 'premium-addons-for-elementor' ),
147 'viewport' => __( 'Viewport', 'premium-addons-for-elementor' ),
148 'hover' => __( 'Hover', 'premium-addons-for-elementor' ),
149 'scroll' => __( 'Scroll', 'premium-addons-for-elementor' ),
150 ],
151 'frontend_available' => true,
152 ]
153 );
154
155 $this->add_control('lottie_hover',
156 [
157 'label' => __('Play on Hover','premium-addons-for-elementor'),
158 'type' => Controls_Manager::HIDDEN,
159 'return_value' => 'true',
160 ]
161 );
162
163 $this->add_control('animate_on_scroll',
164 [
165 'label' => __('Play On Scroll','premium-addons-for-elementor'),
166 'type' => Controls_Manager::HIDDEN,
167 'return_value' => 'true',
168 ]
169 );
170
171 $this->add_control('animate_speed',
172 [
173 'label' => __( 'Speed', 'premium-addons-for-elementor' ),
174 'type' => Controls_Manager::SLIDER,
175 'default' => [
176 'size' => 4,
177 ],
178 'range' => [
179 'px' => [
180 'max' => 10,
181 'step' => 0.1,
182 ],
183 ],
184 'condition' => [
185 'trigger' => 'scroll',
186 'lottie_reverse!' => 'true'
187 ],
188 ]
189 );
190
191 $this->add_control('animate_view',
192 [
193 'label' => __( 'Viewport', 'premium-addons-for-elementor' ),
194 'type' => Controls_Manager::SLIDER,
195 'default' => [
196 'sizes' => [
197 'start' => 0,
198 'end' => 100,
199 ],
200 'unit' => '%',
201 ],
202 'labels' => [
203 __( 'Bottom', 'premium-addons-for-elementor' ),
204 __( 'Top', 'premium-addons-for-elementor' ),
205 ],
206 'scales' => 1,
207 'handles' => 'range',
208 'condition' => [
209 'trigger' => [ 'scroll', 'viewport' ],
210 'lottie_reverse!' => 'true'
211 ],
212 ]
213 );
214
215 $this->add_responsive_control('animation_size',
216 [
217 'label' => __('Size', 'premium-addons-for-elementor'),
218 'type' => Controls_Manager::SLIDER,
219 'size_units' => ['px', 'em', '%'],
220 'default' => [
221 'unit' => 'px',
222 'size' => 200,
223 ],
224 'range' => [
225 'px' => [
226 'min' => 1,
227 'max' => 800,
228 ],
229 'em' => [
230 'min' => 1,
231 'max' => 30,
232 ],
233 ],
234 'render_type' => 'template',
235 'separator' => 'before',
236 'selectors' => [
237 '{{WRAPPER}}.premium-lottie-canvas .premium-lottie-animation, {{WRAPPER}}.premium-lottie-svg svg' => 'width: {{SIZE}}{{UNIT}} !important; height: {{SIZE}}{{UNIT}} !important'
238 ]
239 ]
240 );
241
242 $this->add_responsive_control('lottie_rotate',
243 [
244 'label' => __('Rotate (degrees)', 'premium-addons-for-elementor'),
245 'type' => Controls_Manager::SLIDER,
246 'description' => __('Set rotation value in degrees', 'premium-addons-for-elementor'),
247 'range' => [
248 'px' => [
249 'min' => -180,
250 'max' => 180,
251 ]
252 ],
253 'default' => [
254 'size' => 0,
255 ],
256 'selectors' => [
257 '{{WRAPPER}} .premium-lottie-animation' => 'transform: rotate({{SIZE}}deg)'
258 ],
259 ]
260 );
261
262 $this->add_responsive_control('animation_align',
263 [
264 'label' => __( 'Alignment', 'premium-addons-for-elementor' ),
265 'type' => Controls_Manager::CHOOSE,
266 'options' => [
267 'left' => [
268 'title'=> __( 'Left', 'premium-addons-for-elementor' ),
269 'icon' => 'fa fa-align-left',
270 ],
271 'center' => [
272 'title'=> __( 'Center', 'premium-addons-for-elementor' ),
273 'icon' => 'fa fa-align-center',
274 ],
275 'right' => [
276 'title'=> __( 'Right', 'premium-addons-for-elementor' ),
277 'icon' => 'fa fa-align-right',
278 ],
279 ],
280 'default' => 'center',
281 'toggle' => false,
282 'separator' => 'before',
283 'selectors' => [
284 '{{WRAPPER}} .premium-lottie-wrap' => 'text-align: {{VALUE}}',
285 ],
286 ]
287 );
288
289 $this->add_control('link_switcher',
290 [
291 'label' => __('Link', 'premium-addons-for-elementor'),
292 'type' => Controls_Manager::SWITCHER,
293 ]
294 );
295
296 $this->add_control('link_selection',
297 [
298 'label' => __('Link Type', 'premium-addons-for-elementor'),
299 'type' => Controls_Manager::SELECT,
300 'options' => [
301 'url' => __('URL', 'premium-addons-for-elementor'),
302 'link' => __('Existing Page', 'premium-addons-for-elementor'),
303 ],
304 'default' => 'url',
305 'label_block' => true,
306 'condition' => [
307 'link_switcher' => 'yes'
308 ]
309 ]
310 );
311
312 $this->add_control('link',
313 [
314 'label' => __('Link', 'premium-addons-for-elementor'),
315 'type' => Controls_Manager::URL,
316 'dynamic' => [ 'active' => true ],
317 'default' => [
318 'url' => '#',
319 ],
320 'placeholder' => 'https://premiumaddons.com/',
321 'label_block' => true,
322 'separator' => 'after',
323 'condition' => [
324 'link_switcher' => 'yes',
325 'link_selection' => 'url',
326 ]
327 ]
328 );
329
330 $this->add_control('existing_link',
331 [
332 'label' => __('Existing Page', 'premium-addons-for-elementor'),
333 'type' => Controls_Manager::SELECT2,
334 'options' => $this->getTemplateInstance()->get_all_posts(),
335 'multiple' => false,
336 'label_block' => true,
337 'condition' => [
338 'link_switcher' => 'yes',
339 'link_selection' => 'link',
340 ],
341 ]
342 );
343
344 $this->add_control('lottie_renderer',
345 [
346 'label' => __('Render As', 'premium-addons-for-elementor'),
347 'type' => Controls_Manager::SELECT,
348 'options' => [
349 'svg' => __('SVG', 'premium-addons-for-elementor'),
350 'canvas' => __('Canvas', 'premium-addons-for-elementor'),
351 ],
352 'default' => 'svg',
353 'prefix_class' => 'premium-lottie-',
354 'render_type' => 'template',
355 'label_block' => true,
356 'separator' => 'before'
357 ]
358 );
359
360 $this->add_control('render_notice',
361 [
362 'raw' => __('Set render type to canvas if you\'re having performance issues on the page.', 'premium-addons-for-elemeentor'),
363 'type' => Controls_Manager::RAW_HTML,
364 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
365 ]
366 );
367
368 $this->end_controls_section();
369
370 $this->start_controls_section('section_pa_docs',
371 [
372 'label' => __('Helpful Documentations', 'premium-addons-for-elementor'),
373 ]
374 );
375
376 $docs = [
377 'https://www.youtube.com/watch?v=0QWzUpF57dw' => 'Check the video tutorial »',
378 'https://premiumaddons.com/docs/lottie-animations-widget-tutorial' => 'Check the documentation article »',
379 'https://premiumaddons.com/docs/how-to-speed-up-elementor-pages-with-many-lottie-animations' => 'How to speed up Elementor pages with many Lottie animations »',
380 ];
381
382 $doc_index = 1;
383 foreach( $docs as $url => $title ) {
384
385 $doc_url = Helper_Functions::get_campaign_link( $url, 'editor-page', 'wp-editor', 'get-support' );
386
387 $this->add_control('doc_' . $doc_index,
388 [
389 'type' => Controls_Manager::RAW_HTML,
390 'raw' => sprintf( '<a href="%s" target="_blank">%s</a>', $doc_url , __( $title, 'premium-addons-for-elementor' ) ),
391 'content_classes' => 'editor-pa-doc',
392 ]
393 );
394
395 $doc_index++;
396
397 }
398
399 $this->end_controls_section();
400
401 $this->start_controls_section('section_animation_style',
402 [
403 'label' => __('Animation', 'premium-addons-for-elementor'),
404 'tab' => Controls_Manager::TAB_STYLE,
405 ]
406 );
407
408 $this->start_controls_tabs('tabs_lottie');
409
410 $this->start_controls_tab('tab_lottie_normal',
411 [
412 'label' => __('Normal', 'premium-addons-for-elementor'),
413 ]
414 );
415
416 $this->add_control('lottie_background',
417 [
418 'label' => __('Background Color', 'premium-addons-for-elementor'),
419 'type' => Controls_Manager::COLOR,
420 'selectors' => [
421 '{{WRAPPER}} .premium-lottie-animation' => 'background-color: {{VALUE}}',
422 ]
423 ]
424 );
425
426 $this->add_control('opacity',
427 [
428 'label' => __( 'Opacity', 'premium-addons-for-elementor' ),
429 'type' => Controls_Manager::SLIDER,
430 'range' => [
431 'px' => [
432 'max' => 1,
433 'min' => 0.10,
434 'step' => 0.01,
435 ],
436 ],
437 'selectors' => [
438 '{{WRAPPER}} .premium-lottie-animation' => 'opacity: {{SIZE}}',
439 ],
440 ]
441 );
442
443 $this->add_group_control(
444 Group_Control_Css_Filter::get_type(),
445 [
446 'name' => 'css_filters',
447 'selector' => '{{WRAPPER}} .premium-lottie-animation',
448 ]
449 );
450
451 $this->end_controls_tab();
452
453 $this->start_controls_tab('tab_lottie_hover',
454 [
455 'label' => __('Hover', 'premium-addons-for-elementor'),
456 ]
457 );
458
459 $this->add_control('lottie_hover_background',
460 [
461 'label' => __('Background Color', 'premium-addons-for-elementor'),
462 'type' => Controls_Manager::COLOR,
463 'selectors' => [
464 '{{WRAPPER}} .premium-lottie-animation:hover' => 'background-color: {{VALUE}}',
465 ]
466 ]
467 );
468
469 $this->add_control('hover_opacity',
470 [
471 'label' => __( 'Opacity', 'premium-addons-for-elementor' ),
472 'type' => Controls_Manager::SLIDER,
473 'range' => [
474 'px' => [
475 'max' => 1,
476 'min' => 0.10,
477 'step' => 0.01,
478 ],
479 ],
480 'selectors' => [
481 '{{WRAPPER}} .premium-lottie-animation:hover' => 'opacity: {{SIZE}}',
482 ],
483 ]
484 );
485
486 $this->add_group_control(
487 Group_Control_Css_Filter::get_type(),
488 [
489 'name' => 'hover_css_filters',
490 'selector' => '{{WRAPPER}} .premium-lottie-animation:hover',
491 ]
492 );
493
494 $this->end_controls_tab();
495
496 $this->end_controls_tabs();
497
498 $this->add_group_control(
499 Group_Control_Border::get_type(),
500 [
501 'name' => 'lottie_border',
502 'selector' => '{{WRAPPER}} .premium-lottie-animation',
503 'separator' => 'before'
504 ]
505 );
506
507 $this->add_control('lottie_border_radius',
508 [
509 'label' => __('Border Radius', 'premium-addons-for-elementor'),
510 'type' => Controls_Manager::DIMENSIONS,
511 'size_units' => ['px', '%', 'em'],
512 'selectors' => [
513 '{{WRAPPER}} .premium-lottie-animation' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}'
514 ]
515 ]
516 );
517
518 $this->add_responsive_control('animation_padding',
519 [
520 'label' => __('Padding', 'premium-addons-for-elementor'),
521 'type' => Controls_Manager::DIMENSIONS,
522 'size_units' => ['px', 'em', '%'],
523 'selectors' => [
524 '{{WRAPPER}} .premium-lottie-animation' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}'
525 ],
526 ]
527 );
528
529 $this->end_controls_section();
530
531 }
532
533 /**
534 * Render Lottie Animations output on the frontend.
535 *
536 * Written in PHP and used to generate the final HTML.
537 *
538 * @since 3.20.2
539 * @access protected
540 */
541 protected function render() {
542
543 $settings = $this->get_settings_for_display();
544
545 $anim_url = 'url' === $settings['source'] ? $settings['lottie_url'] : $settings['lottie_file']['url'];
546
547 if( empty( $anim_url ) )
548 return;
549
550 if( '' !== $settings['trigger'] ) {
551 $settings['lottie_hover'] = false;
552 $settings['animate_on_scroll'] = false;
553 }
554
555 $this->add_render_attribute( 'lottie', [
556 'class' => [
557 'premium-lottie-animation',
558 ],
559 'data-lottie-url' => $anim_url,
560 'data-lottie-loop' => $settings['lottie_loop'],
561 'data-lottie-reverse' => $settings['lottie_reverse'],
562 'data-lottie-hover' => $settings['lottie_hover'] || 'hover' === $settings['trigger'],
563 'data-lottie-speed' => $settings['lottie_speed'],
564 'data-lottie-render' => $settings['lottie_renderer'],
565 ]);
566
567 if( $settings['animate_on_scroll'] || 'scroll' === $settings['trigger'] ) {
568
569 $this->add_render_attribute( 'lottie', [
570 'class' => 'premium-lottie-scroll',
571 'data-lottie-scroll' => 'true',
572 'data-scroll-start' => isset ( $settings['animate_view']['sizes']['start'] ) ? $settings['animate_view']['sizes']['start'] : '0',
573 'data-scroll-end' => isset( $settings['animate_view']['sizes']['end'] ) ? $settings['animate_view']['sizes']['end'] : '100',
574 'data-scroll-speed' => $settings['animate_speed']['size'],
575 ]);
576
577 } elseif( 'viewport' === $settings['trigger'] ) {
578 $this->add_render_attribute( 'lottie', [
579 'data-lottie-viewport' => 'true',
580 'data-scroll-start' => $settings['animate_view']['sizes']['start'],
581 'data-scroll-end' => $settings['animate_view']['sizes']['end'],
582 ]);
583 }
584
585 if( 'yes' === $settings['link_switcher'] ) {
586
587 if( $settings['link_selection'] === 'url' ) {
588 $button_url = $settings['link']['url'];
589 } else {
590 $button_url = get_permalink( $settings['existing_link'] );
591 }
592
593 $this->add_render_attribute( 'link', 'href', $button_url );
594
595 if( ! empty( $settings['link']['is_external'] ) )
596 $this->add_render_attribute( 'button', 'target', '_blank' );
597
598 if( ! empty( $settings['link']['nofollow'] ) )
599 $this->add_render_attribute( 'button', 'rel', 'nofollow' );
600
601 }
602
603
604 ?>
605
606 <div class="premium-lottie-wrap">
607 <div <?php echo $this->get_render_attribute_string('lottie'); ?>>
608 <?php if( 'yes' === $settings['link_switcher'] && ! empty( $button_url ) ) : ?>
609 <a <?php echo $this->get_render_attribute_string( 'link' ); ?>></a>
610 <?php endif; ?>
611 </div>
612 </div>
613
614 <?php
615 }
616
617 /**
618 * Render Testimonials widget output in the editor.
619 *
620 * Written as a Backbone JavaScript template and used to generate the live preview.
621 *
622 * @since 3.20.2
623 * @access protected
624 */
625 protected function content_template() {
626
627 ?>
628
629 <#
630
631 var anim_url = 'url' === settings.source ? settings.lottie_url : settings.lottie_file.url;
632
633 if( '' === anim_url )
634 return;
635
636 if( '' !== settings.trigger ) {
637 settings.lottie_hover = false;
638 settings.animate_on_scroll = false;
639 }
640
641 view.addRenderAttribute( 'lottie', {
642 'class': [
643 'premium-lottie-animation',
644 ],
645 'data-lottie-url': anim_url,
646 'data-lottie-loop': settings.lottie_loop,
647 'data-lottie-reverse': settings.lottie_reverse,
648 'data-lottie-hover': settings.lottie_hover || 'hover' === settings.trigger,
649 'data-lottie-speed': settings.lottie_speed,
650 'data-lottie-render': settings.lottie_renderer
651 });
652
653 if( settings.animate_on_scroll || 'scroll' === settings.trigger ) {
654
655 view.addRenderAttribute( 'lottie', {
656 'class': 'premium-lottie-scroll',
657 'data-lottie-scroll': 'true',
658 'data-scroll-start': settings.animate_view.sizes.start,
659 'data-scroll-end': settings.animate_view.sizes.end,
660 'data-scroll-speed': settings.animate_speed.size,
661 });
662
663 } else if( 'viewport' === settings.trigger ) {
664
665 view.addRenderAttribute( 'lottie', {
666 'data-lottie-viewport': 'true',
667 'data-scroll-start': settings.animate_view.sizes.start,
668 'data-scroll-end': settings.animate_view.sizes.end,
669 });
670
671 }
672
673 if( 'yes' === settings.link_switcher ) {
674
675 var button_url = '';
676
677 if( settings.link_selection === 'url' ) {
678 button_url = settings.link.url;
679 } else {
680 button_url = settings.existing_link;
681 }
682
683 view.addRenderAttribute( 'link', 'href', button_url );
684
685 }
686
687
688 #>
689
690 <div class="premium-lottie-wrap">
691 <div {{{ view.getRenderAttributeString('lottie') }}}>
692 <# if( 'yes' === settings.link_switcher && '' !== button_url ) { #>
693 <a {{{ view.getRenderAttributeString('link') }}}></a>
694 <# } #>
695 </div>
696 </div>
697
698 <?php
699 }
700
701
702 }