| @@ -1,0 +1,97 @@ | ||
| 1 | +<?php | |
| 2 | +namespace ABlocks\Controls; | |
| 3 | + | |
| 4 | +use ABlocks\Classes\ControlBaseAbstract; | |
| 5 | + | |
| 6 | +class GsapAnimation extends ControlBaseAbstract { | |
| 7 | + public static function get_attribute_default_value( $is_responsive = false ) { | |
| 8 | + if ( $is_responsive ) { | |
| 9 | + return [ | |
| 10 | + 'animationType' => 'none', | |
| 11 | + 'duration' => 1, | |
| 12 | + 'delay' => 0, | |
| 13 | + 'triggerType' => 'scroll', | |
| 14 | + // from method values | |
| 15 | + 'ease' => 'none', | |
| 16 | + 'x' => 0, | |
| 17 | + 'y' => 0, | |
| 18 | + 'rotation' => 0, | |
| 19 | + 'rotationY' => 0, | |
| 20 | + 'opacity' => 1, | |
| 21 | + // to method values | |
| 22 | + 'xTo' => 0, | |
| 23 | + 'yTo' => 0, | |
| 24 | + 'rotationTo' => 0, | |
| 25 | + 'rotationYTo' => 0, | |
| 26 | + 'opacityTo' => 1, | |
| 27 | + 'easeTo' => 'none', | |
| 28 | + // repeat/loops | |
| 29 | + 'loops' => false, | |
| 30 | + 'numberOfRepeat' => 0, // if -1 then infinite loops | |
| 31 | + 'isSmooth' => true, // yoyo | |
| 32 | + // if animation type 'scroll' then these will work | |
| 33 | + 'startPoint' => 80, // top ${this.attribute?.startPoint ?? 80}% | |
| 34 | + 'endPoint' => 10 | |
| 35 | + ]; | |
| 36 | + | |
| 37 | + }//end if | |
| 38 | + return [ | |
| 39 | + 'animationType' => 'none', | |
| 40 | + 'duration' => 1, | |
| 41 | + 'delay' => 0, | |
| 42 | + 'triggerType' => 'scroll', | |
| 43 | + // from method values | |
| 44 | + 'ease' => 'none', | |
| 45 | + 'x' => 0, | |
| 46 | + 'y' => 0, | |
| 47 | + 'rotation' => 0, | |
| 48 | + 'rotationY' => 0, | |
| 49 | + 'opacity' => 1, | |
| 50 | + // to method values | |
| 51 | + 'xTo' => 0, | |
| 52 | + 'yTo' => 0, | |
| 53 | + 'rotationTo' => 0, | |
| 54 | + 'rotationYTo' => 0, | |
| 55 | + 'opacityTo' => 1, | |
| 56 | + 'easeTo' => 'none', | |
| 57 | + // repeat/loops | |
| 58 | + 'loops' => false, | |
| 59 | + 'numberOfRepeat' => 0, // if -1 then infinite loops | |
| 60 | + 'isSmooth' => true, // yoyo | |
| 61 | + // if animation type 'scroll' then these will work | |
| 62 | + 'startPoint' => 80, // top ${this.attribute?.startPoint ?? 80}% | |
| 63 | + 'endPoint' => 10 | |
| 64 | + ]; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public static function get_attribute( $attributeName, $isResponsive = false ) { | |
| 68 | + return [ | |
| 69 | + $attributeName => [ | |
| 70 | + 'type' => 'object', | |
| 71 | + 'default' => self::get_attribute_default_value( $isResponsive ), | |
| 72 | + ] | |
| 73 | + ]; | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * GSAP animations are driven entirely by the frontend script (see the | |
| 78 | + * gsap view scripts) — this control contributes no CSS. | |
| 79 | + * | |
| 80 | + * The body used to compile a mask-image rule from `mask*` members and then | |
| 81 | + * throw the result away with an unconditional `return []`. Since the control | |
| 82 | + * declares no mask members at all, every one of those reads was an | |
| 83 | + * "Undefined array key" notice on any page carrying a GSAP animation. Dead | |
| 84 | + * code that could only emit warnings, so it is gone; masking lives in the | |
| 85 | + * Mask control. | |
| 86 | + * | |
| 87 | + * @param mixed $attribute_value Stored control value. | |
| 88 | + * @param string $property Unused. | |
| 89 | + * @param string $device Unused. | |
| 90 | + * @return array Always empty. | |
| 91 | + */ | |
| 92 | + public static function get_css( $attribute_value, $property = '', $device = '' ) { | |
| 93 | + return []; | |
| 94 | + } | |
| 95 | + | |
| 96 | + | |
| 97 | +} | |