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 / Animation.php

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

97 lines 2.0 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
5 use Averta\WordPress\Utility\JSON;
6 use Depicter\Document\CSS\Breakpoints;
7
8 class Animation
9 {
10 /**
11 * Animation in phase
12 *
13 * @var object
14 */
15 public $in;
16
17 /**
18 * Animation out phase
19 *
20 * @var object
21 */
22 public $out;
23
24 /**
25 * @var bool|null
26 */
27 public $waitForAction;
28
29 /**
30 * Known phases
31 *
32 * @var array
33 */
34 protected $phases = ['in', 'out'];
35
36
37 /**
38 * @param string $phase
39 * @param string $breakpoint
40 *
41 * @return false|string
42 */
43 public function getAnimation( $phase, $breakpoint ) {
44
45 if( empty( $this->{$phase}->data->{$breakpoint}->type ) || ! isset( $this->{$phase}->data->{$breakpoint}->params ) ){
46 return false;
47 }
48
49 $params = $this->{$phase}->data->{$breakpoint}->params;
50 $params->type = $this->{$phase}->data->{$breakpoint}->type;
51
52 return JSON::encode( $params );
53 }
54
55 private function getWaitForAnimationAttr( $phase, $breakpoint ) {
56
57 }
58
59 /**
60 * Get all animation attributes
61 *
62 * @return array
63 */
64 public function getAnimationAttrs() {
65 $attrs = [];
66
67 // Collect animation attributes
68 foreach ( Breakpoints::names() as $breakpoint ){
69 foreach ( $this->phases as $phase ){
70 $breakpoint_prefix = $breakpoint ? $breakpoint . '-' : $breakpoint;
71 $breakpoint_prefix = $breakpoint == 'default' ? '' : $breakpoint_prefix;
72 if( $animation_value = $this->getAnimation( $phase, $breakpoint ) ){
73 $attrs[ 'data-'. $breakpoint_prefix .'animation-' . $phase ] = $this->getAnimation( $phase, $breakpoint );
74 }
75 }
76 }
77
78 // Get animation interactive attributes
79 if( ! is_null( $this->waitForAction ) ){
80 $attrs[ "data-wait-for-action" ] = $this->waitForAction ? "true" : "false";
81 }
82
83 if( isset( $this->out->wait ) ){
84 $attrs[ "data-animation-out-wait" ] = $this->out->wait ? "true" : "false";
85 }
86
87 // Get animation interactive attributes
88 foreach ( $this->phases as $phase ){
89 if( isset( $this->{$phase}->interactive ) ){
90 $attrs[ "data-animation-{$phase}-interactive" ] = $this->{$phase}->interactive ? "true" : "false";
91 }
92 }
93
94 return $attrs;
95 }
96 }
97