/** * Edit */ const { __ } = wp.i18n; const { InspectorControls, InnerBlocks, } = wp.editor; const { Component, Fragment, } = wp.element; const { PanelBody, SelectControl, ToggleControl, RangeControl, Dashicon, } = wp.components; import { animations, delays, speeds, } from './options'; import classNames from 'classnames'; /** * AnimationBlock */ export class AnimationBlock extends Component { constructor( props ) { super( props ); this.blocksWrap = React.createRef(); } // // Render // render() { const { attributes, setAttributes } = this.props; return ( { setAttributes( { animationIn: value, } ); } } /> { setAttributes( { animationDelay: value, } ); } } /> { setAttributes( { animationSpeed: value, } ); } } /> { setAttributes( { reset: ! attributes.reset, } ); } } /> { setAttributes( { zIndex: value } ); } } min={ 1 } max={ 999 } />

{ __( 'Select Animation Block' ) }

); } // // Did Update // componentDidUpdate( prevProps ) { const blocksWrapEl = this.blocksWrap.current; const { attributes } = this.props; // Provide user preview of the newly applied animation attribute. if ( attributes.animationIn !== prevProps.attributes.animationIn || attributes.animationDelay !== prevProps.attributes.animationDelay || attributes.animationSpeed !== prevProps.attributes.animationSpeed ) { blocksWrapEl.classList.add( attributes.animationIn ); } // Remove animation classes in preparation for next preview. blocksWrapEl.addEventListener( 'animationend', () => { blocksWrapEl.classList.remove( attributes.animationIn ); }, { once: true } ); } }