PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.0.3
UiCore Elements – Free widgets and templates for Elementor v1.0.3
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / utils / animation-component.php

animation-component.php in UiCore Elements – Free widgets and templates for Elementor 1.0.3, at includes/utils/animation-component.php

198 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements\Utils;
3 use Elementor\Controls_Manager;
4
5 defined('ABSPATH') || exit();
6
7 trait Animation_Trait {
8
9 private $animation;
10
11 /**
12 * Registers a hover animation control.
13 *
14 * @param string $name The name of the control.
15 * @param array $conditions Control conditions. (optional)
16 * @param array $filter Animation Filter list. (optional)
17 * @param string|null $custom_slug A custom slug for the control. If null, use $name as slug, formating it. (optional)
18 * @return void
19 */
20 function TRAIT_register_hover_animation_control($name, $conditions = [], $filter = [], $custom_slug = null)
21 {
22 // Custom slug or name converted to slug
23 $slug = isset($custom_slug) ? $custom_slug : strtolower(preg_replace('/\s+/', '_', preg_replace('/[^a-zA-Z0-9\s]/', '', $name)));
24
25 $this->add_control(
26 $slug,
27 [
28 'label' => esc_html__( $name, 'uicore-elements' ),
29 'type' => Controls_Manager::SELECT,
30 'default' => '',
31 'label_block' => true,
32 'options' => $this->uicore_get_animations($filter),
33 'condition' => $conditions
34 ]
35 );
36 }
37 // Entrance Animations Controls.
38 function TRAIT_register_entrance_animations_controls()
39 {
40 $this->add_control(
41 'animate_items',
42 [
43 'label' => esc_html__('Animate each Item', 'uicore-elements'),
44 'type' => Controls_Manager::SWITCHER,
45 'default' => '',
46 'return_value' => 'ui-e-grid-animate',
47 'render_type' => 'none',
48 'frontend_available' => true,
49 ]
50 );
51 $this->add_control(
52 'animate_item_type',
53 [
54 'label' => __( 'Animation', 'uicore-elements' ),
55 'type' => Controls_Manager::SELECT,
56 'default' => 'fadeInUp',
57 'options' => [
58 'fadeInUp' => __( 'Fade In Up', 'uicore-elements' ),
59 'fadeInDown' => __( 'Fade In Down', 'uicore-elements' ),
60 'fadeInLeft' => __( 'Fade In Left', 'uicore-elements' ),
61 'fadeInRight' => __( 'Fade In Right', 'uicore-elements' ),
62 'fadeIn' => __( 'Fade In', 'uicore-elements' ),
63 'zoomIn' => __( 'Zoom In', 'uicore-elements' ),
64 ],
65 'condition' => array(
66 'animate_items' => 'ui-e-grid-animate',
67 ),
68 'frontend_available' => true,
69 ]
70 );
71 $this->add_control(
72 'animate_item_speed',
73 [
74 'label' => __( 'Speed', 'uicore-elements' ),
75 'type' => Controls_Manager::SLIDER,
76 'condition' => array(
77 'animate_items' => 'ui-e-grid-animate',
78 ),
79 'default'=> [
80 'unit' => 'px',
81 'size' => 1500,
82 ],
83 'range' => [
84 'px' => [
85 'min' => 10,
86 'max' => 3000,
87 'step' => 50,
88 ],
89 ],
90 'selectors' => [
91 '{{WRAPPER}}' => '---ui-speed: {{SIZE}}ms',
92 ],
93 ]
94 );
95 $this->add_control(
96 'animate_item_delay',
97 [
98 'label' => __( 'Animation Delay', 'uicore-elements' ),
99 'type' => Controls_Manager::SLIDER,
100 'default'=> [
101 'unit' => 'px',
102 'size' => 200,
103 ],
104 'range' => [
105 'px' => [
106 'min' => 0,
107 'max' => 1500,
108 'step' => 10,
109 ],
110 ],
111 'selectors' => [
112 '{{WRAPPER}}' => '---ui-delay: {{SIZE}}ms',
113 ],
114 'condition' => [
115 'animate_items' => 'ui-e-grid-animate',
116 ],
117 ]
118 );
119 $this->add_control(
120 'animate_item_stagger',
121 [
122 'label' => __( 'Stagger', 'uicore-elements' ),
123 'type' => Controls_Manager::SLIDER,
124 'condition' => array(
125 'animate_items' => 'ui-e-grid-animate',
126 ),
127 'default'=> [
128 'unit' => 'px',
129 'size' => 16,
130 ],
131 'range' => [
132 'px' => [
133 'min' => 4,
134 'max' => 500,
135 'step' => 2,
136 ],
137 ],
138 'selectors' => [
139 '{{WRAPPER}}' => '---ui-stagger: {{SIZE}}ms',
140 ],
141 ]
142 );
143 $this->add_control(
144 'hr',
145 [
146 'type' => \Elementor\Controls_Manager::DIVIDER,
147 'condition' => array(
148 'animate_items' => 'ui-e-grid-animate',
149 ),
150 ]
151 );
152 }
153 // Checks for Uicore Framework or Uicore Animate and acts as condition to get_styles() dependency condition
154 function TRAIT_register_entrace_asset_helper()
155 {
156 $this->add_control(
157 'animation_assets',
158 [
159 'label' => esc_html__( 'Checker', 'uicore-elements' ),
160 'type' => \Elementor\Controls_Manager::HIDDEN,
161 'default' => class_exists('\UiCore\Core') || class_exists('\UiCoreAnimate\Base') ? 'true' : 'false',
162 ]
163 );
164 }
165
166 /**
167 * Retrieves the animations list available for the widget.
168 *
169 * @param array $filter_list Optional. An array of animation names to filter the results.
170 * @return array The list of animations available for the widget.
171 */
172 function uicore_get_animations($filter_list = [])
173 {
174 // Animations
175 $animation_list = [
176 '' => 'None',
177 'translate' => 'Translate',
178 'zoom' => 'Zoom',
179 'fade' => 'Fade',
180 'underline' => 'Underline',
181 ];
182 $list = [];
183 $animation_list = wp_parse_args($this->animation, $animation_list);
184
185 // Filter the list of animations
186 if (!empty($filter_list)) {
187 $animation_list = array_diff_key($animation_list, array_flip($filter_list));
188 }
189
190 // Format the list of animations, with translated strings, to be used as elementor option's array
191 foreach ($animation_list as $key => $value) {
192 $slug = $key !== '' ? "ui-e-item-anim-$key" : '';
193 $list[$slug] = esc_html__($value, 'uicore-elements');
194 }
195
196 return $list;
197 }
198 }