PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Common / Parallax.php

Parallax.php in Depicter — Popup & Slider Builder trunk, at app/src/Document/Models/Common/Parallax.php

67 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Document\Models\Common;
3
4 use Averta\Core\Utility\Data;
5 use Averta\WordPress\Utility\JSON;
6 use Depicter\Document\CSS\Breakpoints;
7 use Depicter\Document\Helper\Helper;
8
9 class Parallax extends States{
10
11 /**
12 * Get all parallax attributes
13 *
14 * @return array
15 */
16 public function getParallaxAttrs() {
17 $attrs = [];
18
19 // Collect animation attributes
20 foreach ( Breakpoints::names() as $breakpoint ){
21 $breakpoint_prefix = $breakpoint ? $breakpoint . '-' : $breakpoint;
22 $breakpoint_prefix = $breakpoint == 'default' ? '' : $breakpoint_prefix;
23
24 if( Helper::isStyleEnabled( $this, $breakpoint, 'enabled' ) ) {
25 $attrs[ 'data-'. $breakpoint_prefix .'parallax' ] = !empty($this->{$breakpoint}->enabled) ? $this->getParallaxOption( $this->{$breakpoint} ) : 'false';
26 }
27
28 }
29
30 return $attrs;
31 }
32
33 /**
34 * Get parallax option
35 *
36 * @param object $parallaxOptions
37 * @return string
38 */
39 public function getParallaxOption( $parallaxOptions ) {
40 $options['type'] = $parallaxOptions->type = $parallaxOptions->type ?? '2d';
41
42 if ( $parallaxOptions->type === '2d' ) {
43 isset( $parallaxOptions->x ) && $options['x'] = $parallaxOptions->x;
44 isset( $parallaxOptions->y ) && $options['y'] = $parallaxOptions->y;
45 } elseif ( $parallaxOptions->type === '3d' ) {
46 isset( $parallaxOptions->x ) && $options['x'] = $parallaxOptions->x;
47 isset( $parallaxOptions->y ) && $options['y'] = $parallaxOptions->y;
48 isset( $parallaxOptions->rx ) && $options['rx'] = $parallaxOptions->rx;
49 isset( $parallaxOptions->ry ) && $options['ry'] = $parallaxOptions->ry;
50 isset( $parallaxOptions->zOrigin ) && $options['zOrigin'] = $parallaxOptions->zOrigin;
51 } elseif ( $parallaxOptions->type == 'scroll' || $parallaxOptions->type == 'viewScroll' ) {
52 isset( $parallaxOptions->dir ) && $options['dir'] = $parallaxOptions->dir;
53 isset( $parallaxOptions->movement ) && $options['movement'] = $parallaxOptions->movement;
54 isset( $parallaxOptions->scale ) && $options['scale'] = $parallaxOptions->scale;
55 isset( $parallaxOptions->rotate ) && $options['rotate'] = $parallaxOptions->rotate;
56 // Add value for following params even if params are not set
57 $options['fade'] = isset( $parallaxOptions->fade ) ? Data::isTrue( $parallaxOptions->fade ) : true;
58 $options['twoWay'] = isset( $parallaxOptions->twoWay ) ? Data::isTrue( $parallaxOptions->twoWay ) : true;
59 }
60
61 $options['smooth'] = isset( $parallaxOptions->smooth ) ? Data::isTrue( $parallaxOptions->smooth ) : true;
62
63 $options['useEntirePage'] = $parallaxOptions->useEntirePage ?? false;
64 return JSON::encode( $options );
65 }
66 }
67