| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Inc\Controls\Group; |
| 4 |
|
| 5 |
use Elementor\Group_Control_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Custom Animate-element group control |
| 14 |
* |
| 15 |
*/ |
| 16 |
class JLTMA_Animation extends Group_Control_Base |
| 17 |
{ |
| 18 |
|
| 19 |
protected static $fields; |
| 20 |
|
| 21 |
public static function get_type() |
| 22 |
{ |
| 23 |
return 'jltma-animation'; |
| 24 |
} |
| 25 |
|
| 26 |
protected function init_fields() |
| 27 |
{ |
| 28 |
$fields = []; |
| 29 |
|
| 30 |
$fields['controls'] = [ |
| 31 |
'label' => '', |
| 32 |
'type' => Controls_Manager::CHOOSE, |
| 33 |
'default' => 'running', |
| 34 |
'toggle' => false, |
| 35 |
'options' => [ |
| 36 |
'running' => [ |
| 37 |
'title' => __('Play', 'master-addons' ), |
| 38 |
'icon' => 'fa fa-play', |
| 39 |
], |
| 40 |
'paused' => [ |
| 41 |
'title' => __('Pause', 'master-addons' ), |
| 42 |
'icon' => 'fa fa-pause', |
| 43 |
], |
| 44 |
], |
| 45 |
'separator' => 'after', |
| 46 |
'selectors' => [ |
| 47 |
'{{SELECTOR}}' => 'animation-play-state: {{VALUE}}; -webkit-animation-play-state: {{VALUE}};', |
| 48 |
], |
| 49 |
]; |
| 50 |
|
| 51 |
$fields['animation'] = [ |
| 52 |
'label' => _x('Animation Type', 'Animation Control', 'master-addons' ), |
| 53 |
'type' => Controls_Manager::SELECT, |
| 54 |
'default' => 'galleggia', |
| 55 |
'options' => [ |
| 56 |
'galleggia' => _x('Float', 'Animation Control', 'master-addons' ), |
| 57 |
'attraversa' => _x('Pass through', 'Animation Control', 'master-addons' ), |
| 58 |
'pulsa' => _x('Pulse', 'Animation Control', 'master-addons' ), |
| 59 |
'dondola' => _x('Swing', 'Animation Control', 'master-addons' ), |
| 60 |
'cresci' => _x('Grow', 'Animation Control', 'master-addons' ), |
| 61 |
'esplodi' => _x('Explode', 'Animation Control', 'master-addons' ), |
| 62 |
'brilla' => _x('Shine', 'Animation Control', 'master-addons' ), |
| 63 |
'risali-o-affonda' => _x('Up or Sink', 'Animation Control', 'master-addons' ), |
| 64 |
'rotola' => _x('Spin', 'Animation Control', 'master-addons' ), |
| 65 |
'gira' => _x('Runs', 'Animation Control', 'master-addons' ), |
| 66 |
'saltella' => _x('Bounce', 'Animation Control', 'master-addons' ), |
| 67 |
], |
| 68 |
'selectors' => [ |
| 69 |
'{{SELECTOR}}' => 'animation-name: {{VALUE}}; -webkit-animation-name: {{VALUE}};', |
| 70 |
], |
| 71 |
]; |
| 72 |
$fields['animation_variation'] = [ |
| 73 |
'label' => _x('Animation Variation', 'Animation Control', 'master-addons' ), |
| 74 |
'type' => Controls_Manager::SELECT, |
| 75 |
'default' => '', |
| 76 |
'options' => [ |
| 77 |
'short' => _x('Short', 'Animation Control', 'master-addons' ), |
| 78 |
'' => _x('Medium', 'Animation Control', 'master-addons' ), |
| 79 |
'long' => _x('Long', 'Animation Control', 'master-addons' ), |
| 80 |
], |
| 81 |
'condition' => [ |
| 82 |
'enabled_animations' => 'yes', |
| 83 |
'animation!' => ['cresci', 'attraversa'], |
| 84 |
], |
| 85 |
'selectors' => [ |
| 86 |
'{{SELECTOR}}' => 'animation-name: {{animation.VALUE}}{{VALUE}}; -webkit-animation-name: {{animation.VALUE}}{{VALUE}};', |
| 87 |
], |
| 88 |
]; |
| 89 |
$fields['transform_origin'] = [ |
| 90 |
'label' => _x('Transform origin', 'Animation Control', 'master-addons' ), |
| 91 |
'type' => Controls_Manager::SELECT, |
| 92 |
'default' => 'center center', |
| 93 |
'options' => [ |
| 94 |
'top left' => _x('Top Left', 'Animation Control', 'master-addons' ), |
| 95 |
'top center' => _x('Top Center', 'Animation Control', 'master-addons' ), |
| 96 |
'top right' => _x('Top Right', 'Animation Control', 'master-addons' ), |
| 97 |
'center left' => _x('Center Left', 'Animation Control', 'master-addons' ), |
| 98 |
'center center' => _x('Center Center', 'Animation Control', 'master-addons' ), |
| 99 |
'center right' => _x('Center Right', 'Animation Control', 'master-addons' ), |
| 100 |
'bottom left' => _x('Bottom Left', 'Animation Control', 'master-addons' ), |
| 101 |
'bottom center' => _x('Bottom Center', 'Animation Control', 'master-addons' ), |
| 102 |
'bottom right' => _x('Bottom Right', 'Animation Control', 'master-addons' ), |
| 103 |
], |
| 104 |
'selectors' => [ |
| 105 |
'{{SELECTOR}}' => 'transform-origin: {{VALUE}}; -webkit-transform-origin: {{VALUE}};', |
| 106 |
], |
| 107 |
]; |
| 108 |
$fields['iteration_mode'] = [ |
| 109 |
'label' => __('Iteration Mode', 'master-addons' ), |
| 110 |
'type' => Controls_Manager::SWITCHER, |
| 111 |
'default' => 'infinite', |
| 112 |
'label_on' => __('Infinite', 'master-addons' ), |
| 113 |
'label_off' => __('Count', 'master-addons' ), |
| 114 |
'return_value' => 'infinite', |
| 115 |
'separator' => 'before', |
| 116 |
'selectors' => [ |
| 117 |
'{{SELECTOR}}' => 'animation-iteration-count: {{VALUE}}; -webkit-animation-iteration-count: {{VALUE}};', |
| 118 |
], |
| 119 |
]; |
| 120 |
$fields['iteration_count'] = [ |
| 121 |
'label' => __('Iteration Count', 'master-addons' ), |
| 122 |
'type' => Controls_Manager::NUMBER, |
| 123 |
'default' => 1, |
| 124 |
'min' => 1, |
| 125 |
'max' => 100, |
| 126 |
'step' => 1, |
| 127 |
'selectors' => [ |
| 128 |
'{{SELECTOR}}' => 'animation-iteration-count: {{VALUE}}; -webkit-animation-iteration-count: {{VALUE}};', |
| 129 |
], |
| 130 |
'condition' => [ |
| 131 |
'iteration_mode' => '', |
| 132 |
], |
| 133 |
]; |
| 134 |
$fields['duration'] = [ |
| 135 |
'label' => _x('Duration', 'Animation Control', 'master-addons' ), |
| 136 |
'type' => Controls_Manager::SLIDER, |
| 137 |
'default' => [ |
| 138 |
'unit' => 's', |
| 139 |
'size' => 1, |
| 140 |
], |
| 141 |
'range' => [ |
| 142 |
's' => [ |
| 143 |
'min' => 0, |
| 144 |
'max' => 20, |
| 145 |
'step' => 0.1, |
| 146 |
], |
| 147 |
], |
| 148 |
'size_units' => ['s'], |
| 149 |
'selectors' => [ |
| 150 |
'{{SELECTOR}}' => 'animation-duration: {{SIZE}}{{UNIT}}; -webkit-animation-duration: {{SIZE}}{{UNIT}};', |
| 151 |
], |
| 152 |
]; |
| 153 |
$fields['delay'] = [ |
| 154 |
'label' => _x('Delay', 'Animation Control', 'master-addons' ), |
| 155 |
'type' => Controls_Manager::SLIDER, |
| 156 |
'default' => [ |
| 157 |
'unit' => 's', |
| 158 |
'size' => 0, |
| 159 |
], |
| 160 |
'range' => [ |
| 161 |
's' => [ |
| 162 |
'min' => 0, |
| 163 |
'max' => 20, |
| 164 |
'step' => 0.1, |
| 165 |
], |
| 166 |
], |
| 167 |
'size_units' => ['s'], |
| 168 |
'selectors' => [ |
| 169 |
'{{SELECTOR}}' => 'animation-delay: {{SIZE}}{{UNIT}}; -webkit-animation-delay: {{SIZE}}{{UNIT}};', |
| 170 |
], |
| 171 |
]; |
| 172 |
|
| 173 |
$fields['timing_function'] = [ |
| 174 |
'label' => _x('Timing Function', 'Animation Control', 'master-addons' ), |
| 175 |
'type' => Controls_Manager::SELECT, |
| 176 |
'default' => 'linear', |
| 177 |
'options' => DCE_Helper::get_anim_timingFunctions(), |
| 178 |
'selectors' => [ |
| 179 |
'{{SELECTOR}}' => 'animation-timing-function: {{VALUE}}; -webkit-animation-timing-function: {{VALUE}};', |
| 180 |
], |
| 181 |
]; |
| 182 |
/* $fields['iteration_mode'] = [ |
| 183 |
'label' => __( 'Iteration Mode', 'master-addons' ), |
| 184 |
'type' => Controls_Manager::CHOOSE, |
| 185 |
'default' => 'counter', |
| 186 |
'options' => [ |
| 187 |
'counter' => [ |
| 188 |
'title' => __( 'Counter', 'master-addons' ), |
| 189 |
'icon' => 'eicon-counter', |
| 190 |
], |
| 191 |
'infinite' => [ |
| 192 |
'title' => __( 'Infinite', 'master-addons' ), |
| 193 |
'icon' => 'eicon-sync', |
| 194 |
], |
| 195 |
'selectors' => [ |
| 196 |
], |
| 197 |
], |
| 198 |
'condition' => [ |
| 199 |
], |
| 200 |
]; */ |
| 201 |
|
| 202 |
$fields['direction'] = [ |
| 203 |
'label' => __('Direction', 'master-addons' ), |
| 204 |
'type' => Controls_Manager::CHOOSE, |
| 205 |
'default' => 'normal', |
| 206 |
'options' => [ |
| 207 |
'normal' => [ |
| 208 |
'title' => __('Normal', 'master-addons' ), |
| 209 |
'icon' => 'eicon-arrow-right', |
| 210 |
], |
| 211 |
'reverse' => [ |
| 212 |
'title' => __('Reverse', 'master-addons' ), |
| 213 |
'icon' => 'eicon-arrow-left', |
| 214 |
], |
| 215 |
'alternate' => [ |
| 216 |
'title' => __('Alternate', 'master-addons' ), |
| 217 |
'icon' => 'fa fa-refresh', |
| 218 |
], |
| 219 |
'alternate-reverse' => [ |
| 220 |
'title' => __('Alternate Reverse', 'master-addons' ), |
| 221 |
'icon' => 'fa fa-retweet', |
| 222 |
], |
| 223 |
], |
| 224 |
'selectors' => [ |
| 225 |
'{{SELECTOR}}' => 'animation-direction: {{VALUE}}; -webkit-animation-direction: {{VALUE}};', |
| 226 |
], |
| 227 |
]; |
| 228 |
$fields['fill_mode'] = [ |
| 229 |
'label' => __('Fill Mode', 'master-addons' ), |
| 230 |
'type' => Controls_Manager::CHOOSE, |
| 231 |
'default' => 'none', |
| 232 |
'options' => [ |
| 233 |
'none' => [ |
| 234 |
'title' => __('None', 'master-addons' ), |
| 235 |
'icon' => 'eicon-close', |
| 236 |
], |
| 237 |
'backwards' => [ |
| 238 |
'title' => __('Backwards', 'master-addons' ), |
| 239 |
'icon' => 'eicon-h-align-right', |
| 240 |
], |
| 241 |
'both' => [ |
| 242 |
'title' => __('Both', 'master-addons' ), |
| 243 |
'icon' => 'eicon-h-align-center', |
| 244 |
], |
| 245 |
'forwards' => [ |
| 246 |
'title' => __('Forwards', 'master-addons' ), |
| 247 |
'icon' => 'eicon-h-align-left', |
| 248 |
], |
| 249 |
], |
| 250 |
'selectors' => [ |
| 251 |
'{{SELECTOR}}' => 'animation-fill-mode: {{VALUE}}; -webkit-animation-fill-mode: {{VALUE}};', |
| 252 |
], |
| 253 |
]; |
| 254 |
|
| 255 |
return $fields; |
| 256 |
} |
| 257 |
|
| 258 |
/* |
| 259 |
animation-timing-function: steps(10); |
| 260 |
|
| 261 |
animation-name: example; |
| 262 |
animation-duration: 4s; |
| 263 |
|
| 264 |
animation-iteration-count: 3; |
| 265 |
animation-iteration-count: infinite; |
| 266 |
|
| 267 |
animation-direction: alternate; |
| 268 |
animation-direction: alternate-reverse; |
| 269 |
|
| 270 |
animation-delay: 2s; |
| 271 |
|
| 272 |
animation-fill-mode: forwards; |
| 273 |
animation-fill-mode: backwards; |
| 274 |
animation-fill-mode: both; |
| 275 |
|
| 276 |
-webkit-animation-timing-function: linear; |
| 277 |
|
| 278 |
animation-play-state: paused; running |
| 279 |
|
| 280 |
animation-timing-function: linear |
| 281 |
animation-timing-function: ease |
| 282 |
animation-timing-function: ease-in |
| 283 |
animation-timing-function: ease-out |
| 284 |
animation-timing-function: ease-in-out |
| 285 |
|
| 286 |
animation: example 5s linear 2s infinite alternate; |
| 287 |
*/ |
| 288 |
|
| 289 |
/** |
| 290 |
* @since 0.5.0 |
| 291 |
* @access protected |
| 292 |
*/ |
| 293 |
protected function get_default_options() |
| 294 |
{ |
| 295 |
return [ |
| 296 |
'popover' => false, |
| 297 |
/* 'popover' => [ |
| 298 |
'starter_title' => _x( 'Animate', 'Animation Control', 'master-addons' ), |
| 299 |
'starter_name' => 'animate_element', |
| 300 |
], */ |
| 301 |
]; |
| 302 |
} |
| 303 |
} |
| 304 |
|