PluginProbe ʕ •ᴥ•ʔ
Happy Addons for Elementor / 3.21.4
Happy Addons for Elementor v3.21.4
3.21.4 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.18.0 2.19.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.21.0 2.21.1 2.22.0 2.22.1 2.23.0 2.24.0 2.24.1 2.25.0 2.26.0 2.27.0 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0 2.8.1 2.9.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.10.2 3.10.3 3.10.4 3.10.5 3.10.6 3.10.7 3.10.8 3.10.9 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 3.12.1 3.12.2 3.12.3 3.12.4 3.12.5 3.12.6 3.13.0 3.14.0 3.14.1 3.15.0 3.15.1 3.15.2 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.18.0 3.18.1 3.19.0 3.2.1 3.2.2 3.20.0 3.20.1 3.20.2 3.20.3 3.20.4 3.20.6 3.20.7 3.20.8 3.21.0 3.21.1 3.21.2 3.21.3 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0 3.7.1 3.7.2 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.9.0 3.9.1 3.9.1.1 0.0.1 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.1 1.2.0 1.2.1 1.3.0 1.3.1 1.4.0 1.4.1 1.5.0 2.0.0 2.1.0 2.10.0 2.11.0 2.11.1 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 trunk
happy-elementor-addons / extensions / background-parallax.php
happy-elementor-addons / extensions Last commit date
advanced-tooltip.php 1 year ago background-overlay.php 1 year ago background-parallax.php 9 months ago column-extended.php 1 year ago css-transform.php 1 year ago custom-js.php 5 months ago custom-mouse-cursor.php 5 months ago equal-height.php 1 year ago fixed-size-button.php 10 months ago floating-effects.php 1 year ago grid-layer.php 1 year ago reading-progress-bar-kit-settings.php 1 year ago reading-progress-bar.php 1 year ago scroll-to-top-kit-settings.php 1 year ago scroll-to-top.php 1 year ago shape-divider.php 9 months ago text-stroke.php 10 months ago walker-nav-menu.php 1 year ago wrapper-link.php 1 year ago
background-parallax.php
349 lines
1 <?php
2
3 namespace Happy_Addons\Elementor\Extensions;
4
5 // Elementor Classes.
6 use Elementor\Controls_Manager;
7 use Elementor\Control_Media;
8 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
9 use Elementor\Group_Control_Background;
10 use Elementor\Group_Control_Border;
11 use Elementor\Group_Control_Box_Shadow;
12 use Elementor\Group_Control_Text_Shadow;
13 use Elementor\Group_Control_Typography;
14
15 defined('ABSPATH') || die();
16
17 class Background_Parallax {
18
19 /**
20 * @var mixed
21 */
22 private static $instance = null;
23
24 /**
25 * @var mixed
26 */
27 private $load_script = null;
28
29 public static function instance() {
30 if (is_null(self::$instance)) {
31 self::$instance = new self();
32 }
33
34 return self::$instance;
35 }
36
37 public function init() {
38
39 add_action( 'elementor/frontend/before_register_scripts', [ $this, 'register_scripts' ] );
40 add_action( 'elementor/frontend/before_register_styles', [ $this, 'register_styles' ] );
41 add_action( 'elementor/preview/enqueue_scripts', [ $this, 'enqueue_preview_scripts' ] );
42
43 add_action('elementor/element/section/section_layout/after_section_end', [ $this, 'register_controls' ], 10);
44 add_action('elementor/element/container/section_layout/after_section_end', [ $this, 'register_controls' ], 10);
45
46 add_action( 'elementor/frontend/section/before_render', [ $this, 'before_render' ], 10, 1 );
47 add_action( 'elementor/frontend/container/before_render', [ $this, 'before_render' ], 10, 1 );
48
49 add_action( 'elementor/section/print_template', array( $this, 'editor_template_print' ), 10, 2 );
50 add_action( 'elementor/container/print_template', array( $this, 'editor_template_print' ), 10, 2 );
51 }
52
53 public function register_scripts() {
54 $suffix = ha_is_script_debug_enabled() ? '.' : '.min.';
55
56 wp_register_script(
57 'jarallax-js',
58 HAPPY_ADDONS_ASSETS . 'vendor/jarallax/jarallax.min.js',
59 null,
60 HAPPY_ADDONS_VERSION,
61 true
62 );
63
64 wp_register_script(
65 'happy-background-parallax',
66 HAPPY_ADDONS_ASSETS . 'js/background-parallax' . $suffix . 'js',
67 [ 'jquery', 'happy-elementor-addons' ],
68 HAPPY_ADDONS_VERSION,
69 true
70 );
71
72 }
73
74 public function register_styles() {
75 wp_register_style(
76 'jarallax-css',
77 HAPPY_ADDONS_ASSETS . 'vendor/jarallax/jarallax.min.css',
78 [],
79 HAPPY_ADDONS_VERSION
80 );
81 }
82
83 public function enqueue_preview_scripts() {
84 wp_enqueue_style( 'jarallax-css' );
85 wp_enqueue_script( 'jarallax-js' );
86 wp_enqueue_script( 'happy-background-parallax' );
87 }
88
89 /**
90 * Register Parallax controls.
91 */
92 public function register_controls( $element ) {
93
94 $element->start_controls_section(
95 'section_ha_bg_parallax',
96 [
97 'label' => ( __( 'Background Parallax', 'happy-elementor-addons') ) . ha_get_section_icon(),
98 'tab' => Controls_Manager::TAB_LAYOUT,
99 ]
100 );
101
102 $element->add_control(
103 'ha_bg_parallax_switcher',
104 [
105 'label' => __( 'Enable BG Parallax', 'happy-elementor-addons' ),
106 'type' => Controls_Manager::SWITCHER,
107 'prefix_class' => 'ha-bg-parallax-',
108 'render_type' => 'template',
109 'style_transfer' => false,
110 'frontend_available' => true,
111 'assets' => [
112 'scripts' => [
113 [
114 'name' => 'jarallax-js',
115 'conditions' => [
116 'terms' => [
117 [
118 'name' => 'ha_bg_parallax_switcher',
119 'operator' => '===',
120 'value' => 'yes',
121 ],
122 ],
123 ],
124 ],
125 [
126 'name' => 'happy-background-parallax',
127 'conditions' => [
128 'terms' => [
129 [
130 'name' => 'ha_bg_parallax_switcher',
131 'operator' => '===',
132 'value' => 'yes',
133 ],
134 ],
135 ],
136 ]
137 ],
138 'styles' => [
139 [
140 'name' => 'jarallax-css',
141 'conditions' => [
142 'terms' => [
143 [
144 'name' => 'ha_bg_parallax_switcher',
145 'operator' => '===',
146 'value' => 'yes',
147 ]
148 ]
149 ]
150 ]
151 ]
152 ],
153 ]
154 );
155
156 $element->add_control(
157 'ha_bg_parallax_update',
158 [
159 'label' => __( 'Apply Button', 'happy-elementor-addons' ),
160 'show_label' => false,
161 'type' => Controls_Manager::RAW_HTML,
162 'raw' => '<div class="elementor-update-preview" style="margin: 0 0 8px 0"><div class="elementor-update-preview-title">' . __( 'Update changes to the page', 'happy-elementor-addons' ) . '</div><div class="elementor-update-preview-button-wrapper"><button class="elementor-update-preview-button elementor-button elementor-button-success" style="background-image: linear-gradient(90deg, #e2498a 0%, #562dd4 100%);">' . __( 'Apply', 'happy-elementor-addons' ) . '</button></div></div>',
163 'condition' => [
164 'ha_bg_parallax_switcher' => 'yes',
165 ],
166 ]
167 );
168
169 $element->add_control(
170 'ha_bg_parallax_type',
171 [
172 'label' => __( 'Type', 'happy-elementor-addons' ),
173 'type' => Controls_Manager::SELECT,
174 'options' => [
175 'scroll' => __( 'Scroll', 'happy-elementor-addons' ),
176 'scroll-opacity' => __( 'Scroll with opacity', 'happy-elementor-addons' ),
177 'opacity' => __( 'Opacity', 'happy-elementor-addons' ),
178 'scale' => __( 'Scale', 'happy-elementor-addons' ),
179 'scale-opacity' => __( 'Scale with opacity', 'happy-elementor-addons' ),
180 'automove' => __( 'Auto Moving', 'happy-elementor-addons' ),
181 ],
182 'label_block' => 'true',
183 'render_type' => 'template',
184 'condition' => [
185 'ha_bg_parallax_switcher' => 'yes'
186 ],
187 'frontend_available' => true,
188 ]
189 );
190
191 $element->add_control(
192 'ha_bg_parallax_automove_direction',
193 [
194 'label' => __( 'Direction', 'happy-elementor-addons' ),
195 'type' => Controls_Manager::SELECT,
196 'options' => [
197 'left' => __( 'Left to Right', 'happy-elementor-addons' ),
198 'right' => __( 'Right to Left', 'happy-elementor-addons' ),
199 'top' => __( 'Top to Bottom', 'happy-elementor-addons' ),
200 'bottom' => __( 'Bottom to Top', 'happy-elementor-addons' )
201 ],
202 'default' => 'left',
203 'condition' => [
204 'ha_bg_parallax_switcher' => 'yes',
205 'ha_bg_parallax_type' => 'automove'
206 ],
207 'frontend_available' => true
208 ]
209 );
210
211 $element->add_control(
212 'ha_bg_parallax_speed',
213 [
214 'label' => __( 'Speed', 'happy-elementor-addons' ),
215 'type' => Controls_Manager::SLIDER,
216 'range' => [
217 'px' => [
218 'min' => -1,
219 'max' => 2,
220 'step' => 0.1
221 ]
222 ],
223 'condition' => [
224 'ha_bg_parallax_switcher' => 'yes',
225 'ha_bg_parallax_type!' => 'automove'
226 ],
227 'frontend_available' => true,
228 ]
229 );
230
231 $element->add_control(
232 'ha_bg_parallax_automove_speed',
233 [
234 'label' => __( 'Speed', 'happy-elementor-addons' ),
235 'type' => Controls_Manager::NUMBER,
236 'default' => 3,
237 'min' => 0,
238 'max' => 150,
239 'description' => __( 'Set the speed of background movement, default: 3', 'happy-elementor-addons' ),
240 'condition' => [
241 'ha_bg_parallax_switcher' => 'yes',
242 'ha_bg_parallax_type' => 'automove'
243 ],
244 'frontend_available' => true
245 ]
246 );
247
248 $element->add_control(
249 'ha_bg_parallax_enable_on_android',
250 [
251 'label' => __( 'Enable on Android', 'happy-elementor-addons' ),
252 'type' => Controls_Manager::SWITCHER,
253 'condition' => [
254 'ha_bg_parallax_switcher' => 'yes',
255 'ha_bg_parallax_type!' => 'automove'
256 ],
257 'frontend_available' => true,
258 ]
259 );
260
261 $element->add_control(
262 'ha_bg_parallax_enable_on_ios',
263 [
264 'label' => __( 'Enable on iOS', 'happy-elementor-addons' ),
265 'type' => Controls_Manager::SWITCHER,
266 'condition' => [
267 'ha_bg_parallax_switcher' => 'yes',
268 'ha_bg_parallax_type!' => 'automove'
269 ],
270 'frontend_available' => true,
271 ]
272 );
273
274 $element->end_controls_section();
275 }
276
277 /**
278 * Render Parallax output on the frontend.
279 */
280 public function before_render( $element ) {
281 $settings = $element->get_settings_for_display();
282 $is_enable = 'yes' === $element->get_settings( 'ha_bg_parallax_switcher' ) ? true : false;
283 $bg_parallax_settings = [
284 'type' => isset( $settings['ha_bg_parallax_type'] ) ? $settings['ha_bg_parallax_type'] : ''
285 ];
286
287 if ( isset( $settings['ha_bg_parallax_type'] ) && '' !== $settings['ha_bg_parallax_type'] && $is_enable ) {
288 if ( 'automove' !== $bg_parallax_settings['type'] ) {
289 $element->add_render_attribute( '_wrapper', 'class', 'ha-bg-parallax-wrap-hide' );
290 $speed = ( isset( $settings['ha_bg_parallax_speed']['size'] ) && ! empty( $settings['ha_bg_parallax_speed']['size'] ) ) ? $settings['ha_bg_parallax_speed']['size'] : 0.5;
291 $bg_parallax_settings['speed'] = $speed;
292 $bg_parallax_settings['android'] ='yes' === $settings['ha_bg_parallax_enable_on_android'] ? 0 : 1;
293 $bg_parallax_settings['ios'] = 'yes' === $settings['ha_bg_parallax_enable_on_ios'] ? 0 : 1;
294 $bg_parallax_settings['size'] = isset( $settings['background_size'] ) ? $settings['background_size'] : 'cover';
295 $bg_parallax_settings['repeat'] = isset( $settings['background_repeat'] ) ? $settings['background_repeat'] : 'no-repeat';
296
297 } elseif ( 'automove' === $bg_parallax_settings['type'] ) {
298 $bg_parallax_settings['speed'] = ! empty( $settings['ha_bg_parallax_automove_speed'] ) ? $settings['ha_bg_parallax_automove_speed'] : 3;
299 $bg_parallax_settings['direction'] = ! empty( $settings['ha_bg_parallax_automove_direction'] ) ? $settings['ha_bg_parallax_automove_direction'] : 'left';
300
301 }
302 $element->add_render_attribute( '_wrapper', 'data-ha-bg-parallax', wp_json_encode( $bg_parallax_settings ) );
303
304 }
305 }
306
307 public function editor_template_print( $template, $widget ) {
308
309 if ( ! $template && 'widget' === $widget->get_type() ) {
310 return;
311 }
312
313 $old_template = $template;
314 ob_start();
315 ?>
316 <#
317 var isEnabled = 'yes' == settings.ha_bg_parallax_switcher ? true : false;
318 if( isEnabled ) {
319 var parallaxSettings = {};
320 parallaxSettings.type = ( "undefined" !== typeof settings.ha_bg_parallax_type && settings.ha_bg_parallax_type ) ? settings.ha_bg_parallax_type: '';
321 if ( "undefined" !== typeof parallaxSettings.type && "automove" !== parallaxSettings.type ) {
322 parallaxSettings.speed = "" !== settings.ha_bg_parallax_speed.size ? settings.ha_bg_parallax_speed.size : 0.5;
323 parallaxSettings.android = "yes" === settings.ha_bg_parallax_enable_on_android ? 0 : 1;
324 parallaxSettings.ios = "yes" === settings.ha_bg_parallax_enable_on_ios ? 0 : 1;
325 parallaxSettings.size = settings.background_size;
326 parallaxSettings.position = settings.background_position;
327 parallaxSettings.repeat = settings.background_repeat;
328 } else {
329 parallaxSettings.speed = "" !== settings.ha_bg_parallax_automove_speed ? settings.ha_bg_parallax_automove_speed : 3 ;
330 parallaxSettings.direction = "" !== settings.ha_bg_parallax_automove_direction ? settings.ha_bg_parallax_automove_direction : 'left';
331 }
332
333 view.addRenderAttribute( 'ha_bg_parallax_data', {
334 'id': 'ha-bg-parallax-' + view.getID(),
335 'data-ha-bg-parallax': JSON.stringify( parallaxSettings )
336 });
337
338 #>
339 <div {{{ view.getRenderAttributeString( 'ha_bg_parallax_data' ) }}}></div>
340 <# } #>
341 <?php
342
343 $parallax_content = ob_get_contents();
344 ob_end_clean();
345 $template = $parallax_content . $old_template;
346 return $template;
347 }
348 }
349