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-background / parallax-background.php

parallax-background.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-background/parallax-background.php

249 lines 7.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\Modules;
4
5 use \Elementor\Element_Base;
6 use \Elementor\Controls_Manager;
7
8 if (!defined('ABSPATH')) exit; // Exit if accessed directly
9
10 /**
11 * Parallax extenstion
12 *
13 * Adds parallax on widgets and columns
14 *
15 * @since 1.2.0
16 */
17 class Parallax_Background extends Element_Base
18 {
19
20 /**
21 * A list of scripts that the widgets is depended in
22 *
23 * @since 1.8.0
24 **/
25 public function get_script_depends()
26 {
27 return [
28 'parallax-background',
29 'jquery-resize-ee',
30 'jquery-visible',
31 ];
32 }
33
34 /**
35 * The description of the current extension
36 *
37 * @since 1.8.0
38 **/
39 public static function get_description()
40 {
41 return __('Adds parallax options for the background image of a section. Can be found under Style &rarr; Background &rarr; Extras if a background image is selected.', 'master-addons');
42 }
43
44 /**
45 * Is disabled by default
46 *
47 * Return wether or not the extension should be disabled by default,
48 * prior to user actually saving a value in the admin page.
49 * Checks if Elementor Pro is enabled to allow for use of Scrolling Effects
50 *
51 * @access public
52 * @since 2.1.0
53 * @return bool
54 */
55 public static function is_default_disabled()
56 {
57 if (is_elementor_pro_active()) {
58 return true;
59 }
60 return false;
61 }
62
63 /**
64 * Add Actions
65 *
66 * @since 1.2.0
67 *
68 * @access private
69 */
70 private function add_controls($element, $args)
71 {
72
73 $element_type = $element->get_type();
74 $elementor_pro_condition = [];
75
76 if (is_elementor_pro_active()) {
77 $elementor_pro_condition = [
78 'background_motion_fx_motion_fx_scrolling' => '', // Elementor Pro Scrolling Effect should be off
79 ];
80 }
81
82 $element->add_control(
83 'parallax_heading',
84 [
85 'type' => Controls_Manager::HEADING,
86 'label' => __('Extras', 'master-addons'),
87 'separator' => 'before',
88 'condition' => array_merge(
89 [
90 'background_background' => ['classic'],
91 'background_image[url]!' => '',
92 ],
93 $elementor_pro_condition
94 ),
95 ]
96 );
97
98 $element->add_control(
99 'parallax_background_enable',
100 [
101 'label' => _x('Parallax Background', 'Parallax Background', 'master-addons'),
102 'type' => Controls_Manager::SWITCHER,
103 'default' => '',
104 'label_on' => __('Yes', 'master-addons'),
105 'label_off' => __('No', 'master-addons'),
106 'return_value' => 'yes',
107 'frontend_available' => true,
108 'condition' => array_merge(
109 [
110 'background_background' => ['classic'],
111 'background_image[url]!' => '',
112 ],
113 $elementor_pro_condition
114 ),
115 ]
116 );
117
118 $element->add_responsive_control(
119 'parallax_background_speed',
120 [
121 'label' => _x('Parallax Speed', 'Parallax Control', 'master-addons'),
122 'type' => Controls_Manager::SLIDER,
123 'default' => [
124 'size' => 0.5,
125 ],
126 'range' => [
127 'px' => [
128 'min' => 0,
129 'max' => 1,
130 'step' => 0.01,
131 ],
132 ],
133 'condition' => array_merge(
134 [
135 'parallax_background_enable!' => '',
136 'background_background' => ['classic'],
137 ],
138 $elementor_pro_condition
139 ),
140 'frontend_available' => true,
141 ]
142 );
143
144 $element->add_control(
145 'parallax_background_direction',
146 [
147 'label' => _x('Parallax Direction', 'Parallax Control', 'master-addons'),
148 'type' => Controls_Manager::SELECT,
149 'default' => 'down',
150 'options' => [
151 'up' => __('Up', 'master-addons'),
152 'down' => __('Down', 'master-addons'),
153 'left' => __('Left', 'master-addons'),
154 'right' => __('Right', 'master-addons'),
155 ],
156 'condition' => array_merge(
157 [
158 'parallax_background_enable!' => '',
159 'background_background' => ['classic'],
160 'background_image[url]!' => '',
161 ],
162 $elementor_pro_condition
163 ),
164 'frontend_available' => true,
165 ]
166 );
167 }
168
169 /**
170 * Update existing background controls
171 *
172 * @since 2.1.0
173 *
174 * @access private
175 */
176 protected function update_background_controls($element)
177 {
178
179 // This is the selector for our transform element
180 $parallax_inner_selector = '{{WRAPPER}}:not(.elementor-motion-effects-element-type-background) > .ee-parallax > .ee-parallax__inner';
181
182 // Make the background image url available in the frontend
183 $element->update_responsive_control('background_image', array(
184 'selectors' => array_merge(
185 [$parallax_inner_selector => 'background-image: url("{{URL}}");'],
186 $element->get_controls('background_image')['selectors']
187 ),
188 'frontend_available' => true,
189 ));
190
191 $element->update_responsive_control('background_position', array(
192 'selectors' => array_merge(
193 [$parallax_inner_selector => 'background-position: {{VALUE}};'],
194 $element->get_controls('background_position')['selectors']
195 ),
196 ));
197
198 $element->update_control('background_attachment', array(
199 'selectors' => array_merge(
200 [$parallax_inner_selector => 'background-attachment: {{VALUE}};'],
201 $element->get_controls('background_attachment')['selectors']
202 ),
203 ));
204
205 $element->update_responsive_control('background_repeat', array(
206 'selectors' => array_merge(
207 [$parallax_inner_selector => 'background-repeat: {{VALUE}};'],
208 $element->get_controls('background_repeat')['selectors']
209 ),
210 ));
211
212 $element->update_responsive_control('background_size', array(
213 'selectors' => array_merge(
214 [$parallax_inner_selector => 'background-size: {{VALUE}};'],
215 $element->get_controls('background_size')['selectors']
216 ),
217 ));
218
219 $element->update_responsive_control('background_bg_width', array(
220 'selectors' => array_merge(
221 [$parallax_inner_selector => 'background-size: {{SIZE}}{{UNIT}} auto'],
222 $element->get_controls('background_bg_width')['selectors']
223 ),
224 ));
225 }
226
227 /**
228 * Add Actions
229 *
230 * @since 1.2.0
231 *
232 * @access private
233 */
234 protected function add_actions()
235 {
236
237 // Activate for widgets
238 add_action('elementor/element/section/section_background/before_section_end', function ($element, $args) {
239
240 $this->update_background_controls($element);
241
242 $this->add_controls($element, $args);
243 }, 10, 2);
244
245 // Activate for columns
246
247 }
248 }
249