PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.9
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 / modules / animation / parallax-elements / parallax-elements.php

parallax-elements.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.9, at inc/modules/animation/parallax-elements/parallax-elements.php

300 lines 9.8 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\Modules\Animation\ParallaxElements;
4
5 use Elementor\Controls_Manager;
6
7 if (!defined('ABSPATH')) exit; // Exit if accessed directly
8
9 /**
10 * Parallax extension
11 *
12 * Adds parallax on widgets and columns
13 *
14 * @since 1.1.3
15 */
16 class Parallax_Elements
17 {
18
19 /**
20 * Is Common Extension
21 *
22 * Defines if the current extension is common for all element types or not
23 *
24 * @since 1.8.0
25 * @access private
26 *
27 * @var bool
28 */
29 protected $is_common = true;
30
31 /**
32 * Constructor
33 *
34 * @since 1.8.0
35 */
36 public function __construct()
37 {
38 $this->add_actions();
39 }
40
41 /**
42 * A list of scripts that the widgets is depended in
43 *
44 * @since 1.8.0
45 **/
46 public function get_script_depends()
47 {
48 return [
49 'parallax-element',
50 'jquery-visible',
51 ];
52 }
53
54 /**
55 * Is disabled by default
56 *
57 * Return wether or not the extension should be disabled by default,
58 * prior to user actually saving a value in the admin page.
59 * Checks if Elementor Pro is enabled to allow for use of Motion Effects
60 *
61 * @access public
62 * @since 2.1.0
63 * @return bool
64 */
65 public static function is_default_disabled()
66 {
67 if (function_exists('is_elementor_pro_active') && is_elementor_pro_active()) {
68 return true;
69 }
70 return false;
71 }
72
73 /**
74 * The description of the current extension
75 *
76 * @since 1.8.0
77 **/
78 public static function get_description()
79 {
80 return __('Adds options to move a column or a widget vertically asynchronously when scrolling the page. Can be found under Advanced &rarr; Master Addons &rarr; Parallax.', 'master-addons');
81 }
82
83 /**
84 * Add Actions
85 *
86 * @since 1.1.3
87 *
88 * @access private
89 */
90 private function add_controls($element, $args)
91 {
92
93 $element_type = $element->get_type();
94
95 $element->add_control(
96 'parallax_element_enable',
97 [
98 'label' => __('Parallax', 'master-addons'),
99 'type' => Controls_Manager::SWITCHER,
100 'default' => '',
101 'label_on' => __('Yes', 'master-addons'),
102 'label_off' => __('No', 'master-addons'),
103 'return_value' => 'yes',
104 'separator' => 'before',
105 'frontend_available' => true,
106 ]
107 );
108
109 $element->add_control(
110 'parallax_element_type',
111 [
112 'label' => __('Type', 'master-addons'),
113 'type' => Controls_Manager::SELECT,
114 'default' => 'scroll',
115 'options' => [
116 'scroll' => __('Scroll', 'master-addons'),
117 'mouse' => __('Mouse', 'master-addons'),
118 ],
119 'condition' => [
120 'parallax_element_enable!' => '',
121 ],
122 'frontend_available' => true,
123 ]
124 );
125
126 $element->add_control(
127 'parallax_element_relative',
128 [
129 'label' => __('Relative to', 'master-addons'),
130 'description' => __('Use "Start position" when the element is visible inside the viewport before scroll.', 'master-addons'),
131 'type' => Controls_Manager::SELECT,
132 'default' => 'middle',
133 'options' => [
134 'middle' => __('Viewport middle', 'master-addons'),
135 'position' => __('Start position', 'master-addons'),
136 ],
137 'condition' => [
138 'parallax_element_enable!' => '',
139 'parallax_element_type' => 'scroll',
140 ],
141 'frontend_available' => true,
142 ]
143 );
144
145 $element->add_control(
146 'parallax_element_pan_relative',
147 [
148 'label' => __('Relative to', 'master-addons'),
149 'type' => Controls_Manager::SELECT,
150 'default' => 'element',
151 'options' => [
152 'element' => __('Element Center', 'master-addons'),
153 'viewport' => __('Viewport Center', 'master-addons'),
154 ],
155 'condition' => [
156 'parallax_element_enable!' => '',
157 'parallax_element_type' => 'mouse',
158 ],
159 'frontend_available' => true,
160 ]
161 );
162
163 $element->add_control(
164 'parallax_element_disable_on',
165 [
166 'label' => __('Disable for', 'master-addons'),
167 'type' => Controls_Manager::SELECT,
168 'default' => 'mobile',
169 'options' => [
170 'none' => __('None', 'master-addons'),
171 'tablet' => __('Mobile and tablet', 'master-addons'),
172 'mobile' => __('Mobile only', 'master-addons'),
173 ],
174 'condition' => [
175 'parallax_element_enable!' => '',
176 'parallax_element_type' => 'scroll',
177 ],
178 'frontend_available' => true,
179 ]
180 );
181
182 $element->add_control(
183 'parallax_element_pan_axis',
184 [
185 'label' => __('Axis', 'master-addons'),
186 'type' => Controls_Manager::SELECT,
187 'default' => 'both',
188 'options' => [
189 'both' => __('Both', 'master-addons'),
190 'vertical' => __('Vertical', 'master-addons'),
191 'horizontal' => __('Horizontal', 'master-addons'),
192 ],
193 'frontend_available' => true,
194 'condition' => [
195 'parallax_element_enable!' => '',
196 'parallax_element_type' => 'mouse',
197 ],
198 ]
199 );
200
201 $element->add_control(
202 'parallax_element_invert',
203 [
204 'label' => __('Invert Direction', 'master-addons'),
205 'type' => Controls_Manager::SWITCHER,
206 'default' => '',
207 'label_on' => __('Yes', 'master-addons'),
208 'label_off' => __('No', 'master-addons'),
209 'return_value' => 'yes',
210 'frontend_available' => true,
211 'condition' => [
212 'parallax_element_enable!' => '',
213 ],
214 ]
215 );
216
217 $element->add_control(
218 'parallax_off_viewport',
219 [
220 'label' => __('Move outside viewport', 'master-addons'),
221 'description' => __('Move elements even if they are not visible', 'master-addons'),
222 'type' => Controls_Manager::SWITCHER,
223 'default' => '',
224 'label_on' => __('Yes', 'master-addons'),
225 'label_off' => __('No', 'master-addons'),
226 'return_value' => 'yes',
227 'frontend_available' => true,
228 'condition' => [
229 'parallax_element_enable!' => '',
230 ],
231 ]
232 );
233
234 $element->add_responsive_control(
235 'parallax_element_pan_distance',
236 [
237 'label' => __('Max Distance (px)', 'master-addons'),
238 'description' => __('The maximum distance from the center of the element and the mouse pointer. Enter 0 or empty to disable.', 'master-addons'),
239 'type' => Controls_Manager::SLIDER,
240 'range' => [
241 'px' => [
242 'min' => 0,
243 'max' => 500,
244 'step' => 1,
245 ],
246 ],
247 'condition' => [
248 'parallax_element_enable!' => '',
249 'parallax_element_type' => 'mouse',
250 'parallax_element_pan_relative' => 'element',
251 ],
252 'frontend_available' => true,
253 ]
254 );
255
256 $element->add_responsive_control(
257 'parallax_element_speed',
258 [
259 'label' => __('Amount', 'master-addons'),
260 'type' => Controls_Manager::SLIDER,
261 'default' => ['size' => 0.15],
262 'range' => [
263 'px' => [
264 'min' => 0.1,
265 'max' => 1,
266 'step' => 0.01,
267 ],
268 ],
269 'condition' => [
270 'parallax_element_enable!' => '',
271 ],
272 'frontend_available' => true,
273 ]
274 );
275 }
276
277 /**
278 * Add Actions
279 *
280 * @since 1.1.3
281 *
282 * @access private
283 */
284 protected function add_actions()
285 {
286
287 // Activate controls for widgets
288 add_action('elementor/element/common/section_master_addons_advanced/before_section_end', function ($element, $args) {
289
290 $this->add_controls($element, $args);
291 }, 10, 2);
292
293 // Activate controls for columns
294 add_action('elementor/element/column/section_master_addons_advanced/before_section_end', function ($element, $args) {
295
296 $this->add_controls($element, $args);
297 }, 10, 2);
298 }
299 }
300