PluginProbe
Depicter — Popup & Slider Builder / 1.5.2
Depicter — Popup & Slider Builder v1.5.2
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 1.5.2, at app/src/Document/Models/Common/Parallax.php

65 lines 2.6 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
8 class Parallax extends States{
9
10 /**
11 * Get all parallax attributes
12 *
13 * @return array
14 */
15 public function getParallaxAttrs() {
16 $attrs = [];
17
18 // Collect animation attributes
19 foreach ( Breakpoints::names() as $breakpoint ){
20 $breakpoint_prefix = $breakpoint ? $breakpoint . '-' : $breakpoint;
21 $breakpoint_prefix = $breakpoint == 'default' ? '' : $breakpoint_prefix;
22
23 if( isset( $this->{$breakpoint}->enabled ) ){
24 $attrs[ 'data-'. $breakpoint_prefix .'parallax' ] = !empty($this->{$breakpoint}->enabled) ? $this->getParallaxOption( $this->{$breakpoint} ) : 'false';
25 }
26
27 }
28
29 return $attrs;
30 }
31
32 /**
33 * Get parallax option
34 *
35 * @param object $parallaxOptions
36 * @return string
37 */
38 public function getParallaxOption( $parallaxOptions ) {
39 $options['type'] = $parallaxOptions->type = $parallaxOptions->type ?? '2d';
40
41 if ( $parallaxOptions->type === '2d' ) {
42 isset( $parallaxOptions->x ) && $options['x'] = $parallaxOptions->x;
43 isset( $parallaxOptions->y ) && $options['y'] = $parallaxOptions->y;
44 } elseif ( $parallaxOptions->type === '3d' ) {
45 isset( $parallaxOptions->x ) && $options['x'] = $parallaxOptions->x;
46 isset( $parallaxOptions->y ) && $options['y'] = $parallaxOptions->y;
47 isset( $parallaxOptions->rx ) && $options['rx'] = $parallaxOptions->rx;
48 isset( $parallaxOptions->ry ) && $options['ry'] = $parallaxOptions->ry;
49 isset( $parallaxOptions->zOrigin ) && $options['zOrigin'] = $parallaxOptions->zOrigin;
50 } elseif ( $parallaxOptions->type == 'scroll' || $parallaxOptions->type == 'viewScroll' ) {
51 isset( $parallaxOptions->dir ) && $options['dir'] = $parallaxOptions->dir;
52 isset( $parallaxOptions->movement ) && $options['movement'] = $parallaxOptions->movement;
53 isset( $parallaxOptions->scale ) && $options['scale'] = $parallaxOptions->scale;
54 isset( $parallaxOptions->rotate ) && $options['rotate'] = $parallaxOptions->rotate;
55 // Add value for following params even if params are not set
56 $options['fade'] = isset( $parallaxOptions->fade ) ? Data::isTrue( $parallaxOptions->fade ) : true;
57 $options['twoWay'] = isset( $parallaxOptions->twoWay ) ? Data::isTrue( $parallaxOptions->twoWay ) : true;
58 }
59
60 $options['smooth'] = isset( $parallaxOptions->smooth ) ? Data::isTrue( $parallaxOptions->smooth ) : true;
61
62 return JSON::encode( $options );
63 }
64 }
65