const preact = require('preact'); const { Component } = require('preact'); const anime = require('animejs').default; const { connect } = require('preact-redux'); const { TIMES } = require('../../constants'); const duration = TIMES.TARGET_DURATION_MS; const addState = connect( function receiveState(state) { const { animCb } = state; return { animCb }; } ); class Siphon extends Component { constructor() { super(); this.animations = []; } render() { return ( ); } componentDidMount() { anime.set('#siphon', { r: '140', stroke: '#3050f8', }); this.animations.push(anime({ targets: '.skill-anim', opacity: [ { value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.3 }, { value: 0, delay: TIMES.TARGET_DURATION_MS * 0.7, duration: TIMES.POST_SKILL_DURATION_MS }, ], })); anime({ targets: '#siphon', keyframes: [ { r: '110', stroke: '#1FF01F' }, { r: '80', stroke: '#1FF01F' }, { r: '50', stroke: '#3050f8' }, { r: '20', stroke: '#3050f8' }, ], delay: TIMES.TARGET_DELAY_MS, duration, easing: 'easeInCubic', }); } componentWillUnmount() { for (let i = this.animations.length - 1; i >= 0; i--) { this.animations[i].reset(); } this.props.animCb(); } } module.exports = addState(Siphon);