PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0
Elementor Website Builder – more than just a page builder v4.1.0
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / controls / hover-animation.php

hover-animation.php in Elementor Website Builder – more than just a page builder 4.1.0, at includes/controls/hover-animation.php

169 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor hover animation control.
10 *
11 * A base control for creating hover animation control. Displays a select box
12 * with the available hover animation effects @see Control_Hover_Animation::get_animations()
13 *
14 * @since 1.0.0
15 */
16 class Control_Hover_Animation extends Base_Data_Control {
17
18 /**
19 * Animations.
20 *
21 * Holds all the available hover animation effects of the control.
22 *
23 * @access private
24 * @static
25 *
26 * @var array
27 */
28 protected static $_animations;
29
30 /**
31 * Get hover animation control type.
32 *
33 * Retrieve the control type, in this case `hover_animation`.
34 *
35 * @since 1.0.0
36 * @access public
37 *
38 * @return string Control type.
39 */
40 public function get_type() {
41 return 'hover_animation';
42 }
43
44 /**
45 * Get animations.
46 *
47 * Retrieve the available hover animation effects.
48 *
49 * @since 1.0.0
50 * @access public
51 * @static
52 *
53 * @return array Available hover animation.
54 */
55 public static function get_animations() {
56 if ( is_null( self::$_animations ) ) {
57 self::$_animations = self::get_default_animations();
58
59 $additional_animations = [];
60
61 /**
62 * Hover animations.
63 *
64 * Filters the animations list displayed in the hover animations control.
65 *
66 * This hook can be used to register new animations in addition to the
67 * basic Elementor hover animations.
68 *
69 * @since 2.4.0
70 *
71 * @param array $additional_animations Additional animations array.
72 */
73 $additional_animations = apply_filters( 'elementor/controls/hover_animations/additional_animations', $additional_animations );
74
75 self::$_animations = array_merge( self::$_animations, $additional_animations );
76 }
77
78 return self::$_animations;
79 }
80
81 public static function get_default_animations(): array {
82 return [
83 'grow' => 'Grow',
84 'shrink' => 'Shrink',
85 'pulse' => 'Pulse',
86 'pulse-grow' => 'Pulse Grow',
87 'pulse-shrink' => 'Pulse Shrink',
88 'push' => 'Push',
89 'pop' => 'Pop',
90 'bounce-in' => 'Bounce In',
91 'bounce-out' => 'Bounce Out',
92 'rotate' => 'Rotate',
93 'grow-rotate' => 'Grow Rotate',
94 'float' => 'Float',
95 'sink' => 'Sink',
96 'bob' => 'Bob',
97 'hang' => 'Hang',
98 'skew' => 'Skew',
99 'skew-forward' => 'Skew Forward',
100 'skew-backward' => 'Skew Backward',
101 'wobble-vertical' => 'Wobble Vertical',
102 'wobble-horizontal' => 'Wobble Horizontal',
103 'wobble-to-bottom-right' => 'Wobble To Bottom Right',
104 'wobble-to-top-right' => 'Wobble To Top Right',
105 'wobble-top' => 'Wobble Top',
106 'wobble-bottom' => 'Wobble Bottom',
107 'wobble-skew' => 'Wobble Skew',
108 'buzz' => 'Buzz',
109 'buzz-out' => 'Buzz Out',
110 ];
111 }
112
113 /**
114 * Render hover animation control output in the editor.
115 *
116 * Used to generate the control HTML in the editor using Underscore JS
117 * template. The variables for the class are available using `data` JS
118 * object.
119 *
120 * @since 1.0.0
121 * @access public
122 */
123 public function content_template() {
124 ?>
125 <div class="elementor-control-field">
126 <label for="<?php $this->print_control_uid(); ?>" class="elementor-control-title">{{{ data.label }}}</label>
127 <div class="elementor-control-input-wrapper">
128 <select id="<?php $this->print_control_uid(); ?>" data-setting="{{ data.name }}">
129 <option value=""><?php echo esc_html__( 'None', 'elementor' ); ?></option>
130 <?php foreach ( static::get_animations() as $animation_name => $animation_title ) : ?>
131 <option value="<?php Utils::print_unescaped_internal_string( $animation_name ); ?>"><?php Utils::print_unescaped_internal_string( $animation_title ); ?></option>
132 <?php endforeach; ?>
133 </select>
134 </div>
135 </div>
136 <# if ( data.description ) { #>
137 <div class="elementor-control-field-description">{{{ data.description }}}</div>
138 <# } #>
139 <?php
140 }
141
142 /**
143 * Get hover animation control default settings.
144 *
145 * Retrieve the default settings of the hover animation control. Used to return
146 * the default settings while initializing the hover animation control.
147 *
148 * @since 1.0.0
149 * @access protected
150 *
151 * @return array Control default settings.
152 */
153 protected function get_default_settings() {
154 return [
155 'label_block' => true,
156 ];
157 }
158
159 public static function get_assets( $setting ) {
160 if ( ! $setting || 'none' === $setting ) {
161 return [];
162 }
163
164 return [
165 'styles' => [ 'e-animation-' . $setting ],
166 ];
167 }
168 }
169