PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / trunk
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits vtrunk
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / classes / animation.php

animation.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits trunk, at inc/classes/animation.php

792 lines 29.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Inc\Classes;
4
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7
8 if (!defined('ABSPATH')) {
9 exit; // Exit if accessed directly
10 }
11
12 if (!class_exists('MasterAddons\Inc\Classes\Animation')) {
13 class Animation
14 {
15 /**
16 * Register widget controls.
17 *
18 * Adds base animation controls.
19 */
20 public static function register_section_animation(Widget_Base $element, $is_multiple, $condition)
21 {
22 if (true === $is_multiple) {
23 $pointer_options = array(
24 'none' => __('None', 'master-addons' ),
25 'underline' => __('Underline', 'master-addons' ),
26 'overline' => __('Overline', 'master-addons' ),
27 'background' => __('Background', 'master-addons' ),
28 'text' => __('Text', 'master-addons' ),
29 );
30 } else {
31 $pointer_options = array(
32 'none' => __('None', 'master-addons' ),
33 'underline' => __('Underline', 'master-addons' ),
34 'overline' => __('Overline', 'master-addons' ),
35 'background' => __('Background', 'master-addons' ),
36 );
37 }
38
39 $element->start_controls_section(
40 'animation',
41 array(
42 'label' => __('Pointer Animation', 'master-addons' ),
43 'tab' => Controls_Manager::TAB_STYLE,
44 'conditions' => $condition,
45 )
46 );
47
48 $element->add_control(
49 'pointer',
50 array(
51 'label' => __('Hover Effect', 'master-addons' ),
52 'type' => Controls_Manager::SELECT,
53 'default' => 'none',
54 'options' => $pointer_options,
55 'render_type' => 'template',
56 'prefix_class' => 'jltma-pointer-',
57 'style_transfer' => true,
58 )
59 );
60
61 $element->add_control(
62 'animation_line',
63 array(
64 'label' => __('Animation', 'master-addons' ),
65 'type' => Controls_Manager::SELECT,
66 'default' => 'slide',
67 'options' => array(
68 'slide' => 'Slide',
69 'grow' => 'Grow',
70 'drop-in' => 'Drop In',
71 'drop-out' => 'Drop Out',
72 'none' => 'None',
73 ),
74 'render_type' => 'template',
75 'prefix_class' => 'jltma-animation-',
76 'condition' => array(
77 'pointer' => array('overline'),
78 ),
79 )
80 );
81
82 $element->add_control(
83 'animation_underline',
84 array(
85 'label' => __('Animation', 'master-addons' ),
86 'type' => Controls_Manager::SELECT,
87 'default' => 'slide',
88 'options' => array(
89 'slide' => 'Slide',
90 'grow' => 'Grow',
91 'drop-in' => 'Drop In',
92 'drop-out' => 'Drop Out',
93 'none' => 'None',
94 ),
95 'render_type' => 'template',
96 'prefix_class' => 'jltma-animation-',
97 'condition' => array(
98 'pointer' => array('underline'),
99 ),
100 )
101 );
102
103 $element->add_control(
104 'animation_background',
105 array(
106 'label' => __('Animation', 'master-addons' ),
107 'type' => 'jltma-choose-text',
108 'options' => array(
109 'sweep-filling' => array(
110 'title' => __('Sweep', 'master-addons' ),
111 'description' => __('Sweep Filling', 'master-addons' ),
112 ),
113 'grow' => array(
114 'title' => __('Grow', 'master-addons' ),
115 ),
116 ),
117 'default' => 'sweep-filling',
118 'label_block' => false,
119 'toggle' => false,
120 'render_type' => 'template',
121 'prefix_class' => 'jltma-animation-',
122 'condition' => array('pointer' => 'background'),
123 )
124 );
125
126 $element->add_control(
127 'animation_text',
128 [
129 'label' => __('Animation', 'master-addons' ),
130 'type' => Controls_Manager::SELECT,
131 'default' => 'grow',
132 'options' => [
133 'grow' => 'Grow',
134 'shrink' => 'Shrink',
135 'sink' => 'Sink',
136 'float' => 'Float',
137 'skew' => 'Skew',
138 'rotate' => 'Rotate',
139 ],
140 'render_type' => 'template',
141 'prefix_class' => 'jltma-animation-',
142 'condition' => [
143 'pointer' => 'text',
144 ],
145 ]
146 );
147
148 $element->add_control(
149 'animation_filling_direction',
150 array(
151 'label' => __('Sweep Direction', 'master-addons' ),
152 'type' => 'jltma-choose-text',
153 'options' => array(
154 'sweep-left' => array(
155 'title' => __('Left', 'master-addons' ),
156 'description' => __('Sweep Left', 'master-addons' ),
157 ),
158 'sweep-right' => array(
159 'title' => __('Right', 'master-addons' ),
160 'description' => __('Sweep Right', 'master-addons' ),
161 ),
162 'sweep-top' => array(
163 'title' => __('Top', 'master-addons' ),
164 'description' => __('Sweep Top', 'master-addons' ),
165 ),
166 'sweep-bottom' => array(
167 'title' => __('Bottom', 'master-addons' ),
168 'description' => __('Sweep Bottom', 'master-addons' ),
169 ),
170 ),
171 'label_block' => true,
172 'toggle' => false,
173 'render_type' => 'template',
174 'default' => 'sweep-top',
175 'prefix_class' => 'jltma-direction-',
176 'conditions' => array(
177 'relation' => 'and',
178 'terms' => array(
179 array(
180 'name' => 'pointer',
181 'operator' => '=',
182 'value' => 'background',
183 ),
184 array(
185 'name' => 'animation_background',
186 'operator' => '=',
187 'value' => 'sweep-filling',
188 ),
189 ),
190 ),
191 )
192 );
193
194 $element->add_control(
195 'animation_background_side',
196 array(
197 'label' => __('Side', 'master-addons' ),
198 'type' => 'jltma-choose-text',
199 'options' => array(
200 'left' => array('title' => __('Left', 'master-addons' )),
201 'right' => array('title' => __('Right', 'master-addons' )),
202 'top' => array('title' => __('Top', 'master-addons' )),
203 'bottom' => array('title' => __('Bottom', 'master-addons' )),
204 ),
205 'label_block' => true,
206 'toggle' => false,
207 'render_type' => 'template',
208 'default' => 'bottom',
209 'prefix_class' => 'jltma-animation-side-',
210 'conditions' => array(
211 'relation' => 'and',
212 'terms' => array(
213 array(
214 'name' => 'pointer',
215 'operator' => '=',
216 'value' => 'background',
217 ),
218 array(
219 'name' => 'animation_background',
220 'operator' => '=',
221 'value' => 'advanced-filling-xy',
222 ),
223 ),
224 ),
225 )
226 );
227
228 $element->add_control(
229 'animation_background_position_y',
230 array(
231 'label' => __('Position', 'master-addons' ),
232 'type' => 'jltma-choose-text',
233 'options' => array(
234 'top' => array('title' => __('Top', 'master-addons' )),
235 'center' => array('title' => __('Center', 'master-addons' )),
236 'bottom' => array('title' => __('Bottom', 'master-addons' )),
237 ),
238 'label_block' => true,
239 'toggle' => false,
240 'default' => 'center',
241 'selectors_dictionary' => array(
242 'top' => 'top: 0;',
243 'bottom' => 'bottom: 0;',
244 'center' => 'top: 0; bottom: 0;',
245 ),
246 'selectors' => array(
247 '{{WRAPPER}}.jltma-animation-advanced-filling-xy .jltma-animation:after' => '{{VALUE}}',
248 ),
249 'conditions' => array(
250 'relation' => 'and',
251 'terms' => array(
252 array(
253 'name' => 'pointer',
254 'operator' => '=',
255 'value' => 'background',
256 ),
257 array(
258 'name' => 'animation_background',
259 'operator' => '=',
260 'value' => 'advanced-filling-xy',
261 ),
262 array(
263 'relation' => 'or',
264 'terms' => array(
265 array(
266 'name' => 'animation_background_side',
267 'operator' => '=',
268 'value' => 'left',
269 ),
270 array(
271 'name' => 'animation_background_side',
272 'operator' => '=',
273 'value' => 'right',
274 ),
275 ),
276 ),
277 ),
278 ),
279 )
280 );
281
282 $element->add_control(
283 'animation_background_position_x',
284 array(
285 'label' => __('Start Position', 'master-addons' ),
286 'type' => 'jltma-choose-text',
287 'options' => array(
288 'left' => array('title' => __('Left', 'master-addons' )),
289 'center' => array('title' => __('Center', 'master-addons' )),
290 'right' => array('title' => __('Right', 'master-addons' )),
291 ),
292 'label_block' => true,
293 'toggle' => false,
294 'default' => 'center',
295 'selectors_dictionary' => array(
296 'left' => 'left: 0;',
297 'right' => 'right: 0;',
298 'center' => 'left: 0; right: 0;',
299 ),
300 'selectors' => array(
301 '{{WRAPPER}}.jltma-animation-advanced-filling-xy .jltma-animation:after' => '{{VALUE}}',
302 ),
303 'conditions' => array(
304 'relation' => 'and',
305 'terms' => array(
306 array(
307 'name' => 'pointer',
308 'operator' => '=',
309 'value' => 'background',
310 ),
311 array(
312 'name' => 'animation_background',
313 'operator' => '=',
314 'value' => 'advanced-filling-xy',
315 ),
316 array(
317 'relation' => 'or',
318 'terms' => array(
319 array(
320 'name' => 'animation_background_side',
321 'operator' => '=',
322 'value' => 'top',
323 ),
324 array(
325 'name' => 'animation_background_side',
326 'operator' => '=',
327 'value' => 'bottom',
328 ),
329 ),
330 ),
331 ),
332 ),
333 )
334 );
335
336 self::register_section_style_animation_advanced($element, $is_multiple);
337
338 $element->end_controls_section();
339 }
340
341 /**
342 * Register advanced widget controls.
343 *
344 * Adds additional controls, that adds lots of variations.
345 */
346 public static function register_section_style_animation_advanced(Widget_Base $element, $is_multiple)
347 {
348 $element->add_control(
349 'animation_advanced_size',
350 array(
351 'label' => __('Line Size', 'master-addons' ),
352 'type' => Controls_Manager::SLIDER,
353 'default' => array(
354 'unit' => 'px',
355 'size' => '4',
356 ),
357 'size_units' => array('px', '%', 'em'),
358 'range' => array(
359 'px' => array(
360 'min' => 0,
361 'max' => 100,
362 ),
363 '%' => array(
364 'min' => 0,
365 'max' => 100,
366 ),
367 'em' => array(
368 'min' => 0,
369 'max' => 50,
370 ),
371 ),
372 'selectors' => array(
373 '{{WRAPPER}}' => '--animation-line-size: {{SIZE}}{{UNIT}};',
374 ),
375 'conditions' => array(
376 'relation' => 'and',
377 'terms' => array(
378 array(
379 'name' => 'pointer',
380 'operator' => '!==',
381 'value' => 'none',
382 ),
383 array(
384 'name' => 'pointer',
385 'operator' => '!==',
386 'value' => 'background',
387 ),
388 array(
389 'name' => 'pointer',
390 'operator' => '!==',
391 'value' => 'text',
392 ),
393 ),
394 ),
395 )
396 );
397
398 $element->add_control(
399 'animation_line_position',
400 array(
401 'label' => __('Position', 'master-addons' ),
402 'type' => Controls_Manager::SLIDER,
403 'size_units' => array('px', '%'),
404 'range' => array(
405 'px' => array(
406 'min' => 0,
407 'max' => 100,
408 ),
409 '%' => array(
410 'min' => 0,
411 'max' => 50,
412 ),
413 ),
414 'selectors' => array(
415 '{{WRAPPER}}' => '--animation-line-background-position: {{SIZE}}{{UNIT}};',
416 ),
417 'conditions' => array(
418 'relation' => 'and',
419 'terms' => array(
420 array(
421 'name' => 'pointer',
422 'operator' => '!==',
423 'value' => 'none',
424 ),
425 array(
426 'name' => 'pointer',
427 'operator' => '!==',
428 'value' => 'background',
429 ),
430 array(
431 'relation' => 'or',
432 'terms' => array(
433 array(
434 'name' => 'pointer',
435 'operator' => '=',
436 'value' => 'underline',
437 ),
438 array(
439 'name' => 'pointer',
440 'operator' => '=',
441 'value' => 'overline',
442 ),
443 ),
444 ),
445 ),
446 ),
447 )
448 );
449
450 $element->add_control(
451 'animation_use_gradient',
452 array(
453 'label' => __('Use Gradient', 'master-addons' ),
454 'type' => Controls_Manager::SWITCHER,
455 'render_type' => 'template',
456 'prefix_class' => 'jltma-animation-use-gradient-',
457 'conditions' => array(
458 'relation' => 'and',
459 'terms' => array(
460 array(
461 'name' => 'pointer',
462 'operator' => '!==',
463 'value' => 'none',
464 ),
465 array(
466 'name' => 'pointer',
467 'operator' => '!==',
468 'value' => 'text',
469 ),
470 ),
471 ),
472 )
473 );
474
475 $element->add_control(
476 'animation_color',
477 array(
478 'label' => __('Color', 'master-addons' ),
479 'type' => Controls_Manager::COLOR,
480 'default' => '',
481 'selectors' => array(
482 '{{WRAPPER}}' => '--animation-color: {{VALUE}}',
483 ),
484 'conditions' => array(
485 'relation' => 'and',
486 'terms' => array(
487 array(
488 'name' => 'pointer',
489 'operator' => '!==',
490 'value' => 'none',
491 ),
492 array(
493 'name' => 'pointer',
494 'operator' => '!==',
495 'value' => 'text',
496 ),
497 ),
498 ),
499 )
500 );
501
502 $element->add_control(
503 'animation_color_stop',
504 array(
505 'label' => __('Location', 'master-addons' ),
506 'type' => Controls_Manager::SLIDER,
507 'size_units' => array('%'),
508 'default' => array(
509 'unit' => '%',
510 'size' => 0,
511 ),
512 'selectors' => array(
513 '{{WRAPPER}}' => '--animation-color-stop: {{SIZE}}{{UNIT}}',
514 ),
515 'conditions' => array(
516 'relation' => 'and',
517 'terms' => array(
518 array(
519 'name' => 'pointer',
520 'operator' => '!==',
521 'value' => 'none',
522 ),
523 array(
524 'name' => 'pointer',
525 'operator' => '!==',
526 'value' => 'text',
527 ),
528 array(
529 'name' => 'animation_use_gradient',
530 'operator' => '=',
531 'value' => 'yes',
532 ),
533 ),
534 ),
535 )
536 );
537
538 $element->add_control(
539 'animation_second_color',
540 array(
541 'label' => __('Second Color', 'master-addons' ),
542 'type' => Controls_Manager::COLOR,
543 'default' => '',
544 'selectors' => array(
545 '{{WRAPPER}}' => '--animation-second-color: {{VALUE}}',
546 ),
547 'conditions' => array(
548 'relation' => 'and',
549 'terms' => array(
550 array(
551 'name' => 'pointer',
552 'operator' => '!==',
553 'value' => 'none',
554 ),
555 array(
556 'name' => 'pointer',
557 'operator' => '!==',
558 'value' => 'text',
559 ),
560 array(
561 'name' => 'animation_use_gradient',
562 'operator' => '=',
563 'value' => 'yes',
564 ),
565 ),
566 ),
567 )
568 );
569
570 $element->add_control(
571 'animation_second_color_stop',
572 array(
573 'label' => __('Location', 'master-addons' ),
574 'type' => Controls_Manager::SLIDER,
575 'size_units' => array('%'),
576 'default' => array(
577 'unit' => '%',
578 'size' => 100,
579 ),
580 'selectors' => array(
581 '{{WRAPPER}}' => '--animation-second-color-stop: {{SIZE}}{{UNIT}}',
582 ),
583 'conditions' => array(
584 'relation' => 'and',
585 'terms' => array(
586 array(
587 'name' => 'pointer',
588 'operator' => '!==',
589 'value' => 'none',
590 ),
591 array(
592 'name' => 'pointer',
593 'operator' => '!==',
594 'value' => 'text',
595 ),
596 array(
597 'name' => 'animation_use_gradient',
598 'operator' => '=',
599 'value' => 'yes',
600 ),
601 ),
602 ),
603 )
604 );
605
606 $element->add_control(
607 'animation_gradient_type',
608 array(
609 'label' => _x('Type', 'Background Control', 'master-addons' ),
610 'type' => Controls_Manager::SELECT,
611 'options' => array(
612 'linear' => _x('Linear', 'Background Control', 'master-addons' ),
613 'radial' => _x('Radial', 'Background Control', 'master-addons' ),
614 ),
615 'default' => 'linear',
616 'prefix_class' => 'jltma-color-gradient-',
617 'render_type' => 'template',
618 'conditions' => array(
619 'relation' => 'and',
620 'terms' => array(
621 array(
622 'name' => 'pointer',
623 'operator' => '!==',
624 'value' => 'none',
625 ),
626 array(
627 'name' => 'pointer',
628 'operator' => '!==',
629 'value' => 'text',
630 ),
631 array(
632 'name' => 'animation_use_gradient',
633 'operator' => '=',
634 'value' => 'yes',
635 ),
636 ),
637 ),
638 )
639 );
640
641 $element->add_control(
642 'animation_gradient_angle',
643 array(
644 'label' => _x('Angle', 'Background Control', 'master-addons' ),
645 'type' => Controls_Manager::SLIDER,
646 'size_units' => array('deg'),
647 'default' => array(
648 'unit' => 'deg',
649 'size' => 90,
650 ),
651 'range' => array(
652 'deg' => array('step' => 10),
653 ),
654 'selectors' => array(
655 '{{WRAPPER}}' => '--animation-gradient-angle: {{SIZE}}{{UNIT}}',
656 ),
657 'conditions' => array(
658 'relation' => 'and',
659 'terms' => array(
660 array(
661 'name' => 'pointer',
662 'operator' => '!==',
663 'value' => 'none',
664 ),
665 array(
666 'name' => 'pointer',
667 'operator' => '!==',
668 'value' => 'text',
669 ),
670 array(
671 'name' => 'animation_use_gradient',
672 'operator' => '=',
673 'value' => 'yes',
674 ),
675 array(
676 'name' => 'animation_gradient_type',
677 'operator' => '=',
678 'value' => 'linear',
679 ),
680 ),
681 ),
682 )
683 );
684
685 $element->add_control(
686 'animation_gradient_position',
687 array(
688 'label' => _x('Position', 'Background Control', 'master-addons' ),
689 'type' => Controls_Manager::SELECT,
690 'options' => array(
691 'center center' => _x('Center Center', 'Background Control', 'master-addons' ),
692 'center left' => _x('Center Left', 'Background Control', 'master-addons' ),
693 'center right' => _x('Center Right', 'Background Control', 'master-addons' ),
694 'top center' => _x('Top Center', 'Background Control', 'master-addons' ),
695 'top left' => _x('Top Left', 'Background Control', 'master-addons' ),
696 'top right' => _x('Top Right', 'Background Control', 'master-addons' ),
697 'bottom center' => _x('Bottom Center', 'Background Control', 'master-addons' ),
698 'bottom left' => _x('Bottom Left', 'Background Control', 'master-addons' ),
699 'bottom right' => _x('Bottom Right', 'Background Control', 'master-addons' ),
700 ),
701 'default' => 'center center',
702 'selectors' => array(
703 '{{WRAPPER}}' => '--animation-gradient-radial: at {{VALUE}}',
704 ),
705 'conditions' => array(
706 'relation' => 'and',
707 'terms' => array(
708 array(
709 'name' => 'pointer',
710 'operator' => '!==',
711 'value' => 'none',
712 ),
713 array(
714 'name' => 'pointer',
715 'operator' => '!==',
716 'value' => 'text',
717 ),
718 array(
719 'name' => 'animation_use_gradient',
720 'operator' => '=',
721 'value' => 'yes',
722 ),
723 array(
724 'name' => 'animation_gradient_type',
725 'operator' => '=',
726 'value' => 'radial',
727 ),
728 ),
729 ),
730 )
731 );
732
733 $element->add_control(
734 'divider_after_gradient',
735 array(
736 'type' => Controls_Manager::DIVIDER,
737 'condition' => array('animation_use_gradient' => 'yes'),
738 )
739 );
740
741 $element->add_control(
742 'animation_advanced_transition',
743 array(
744 'label' => __('Transition Duration', 'master-addons' ),
745 'type' => Controls_Manager::SLIDER,
746 'default' => array('size' => 0.3),
747 'range' => array(
748 'px' => array(
749 'max' => 3,
750 'step' => 0.1,
751 ),
752 ),
753 'selectors' => array(
754 '{{WRAPPER}}' => '--animation-transition-duration: {{SIZE}}s;',
755 ),
756 'conditions' => array(
757 'relation' => 'or',
758 'terms' => array(
759 array(
760 'name' => 'pointer',
761 'operator' => '!==',
762 'value' => 'none',
763 ),
764 ),
765 ),
766 )
767 );
768 }
769
770 /**
771 * Register widget controls.
772 *
773 * Adds different input fields to allow the user to change and customize the widget settings.
774 *
775 */
776 public static function register_sections_controls(Widget_Base $element, $is_multiple = true, $condition = '')
777 {
778 self::register_section_animation($element, $is_multiple, $condition);
779 }
780
781 /**
782 * Get animation class.
783 */
784 public static function get_animation_class()
785 {
786 $class = 'jltma-animation';
787
788 return $class;
789 }
790 } // End class Animation
791 } // End class_exists check
792