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 }; } ); function projectile(x, y, radius, colour) { return ( ); } class SiphonTick extends Component { constructor(props) { super(); this.team = props.team; this.animations = []; this.colour = '#3498db'; const points = new Array(15).fill(0); this.charges = points.map(() => projectile(150, 150, 7, '#1FF01F')); } render() { return ( {this.charges} ); } componentDidMount() { if (!this.props.team) { anime.set('.skill-anim', { rotate: 90, }); } else { anime.set('.skill-anim', { rotate: 270, }); } anime.set('.skill-anim circle', { cx: 150, cy: 150, }); anime.set('#siphon', { r: '80', stroke: '#3498db', }); anime({ targets: '#siphon', keyframes: [ { r: '50', stroke: '#3498db' }, { r: '20', stroke: '#3498db' }, { r: '0', stroke: '#3498db' }, ], duration: duration * 2 / 3, easing: 'easeInCubic', }); const projectiles = document.querySelectorAll('.skill-anim circle'); projectiles.forEach(proj => { anime({ targets: proj, cx: Math.random() * 250 + 25, cy: Math.random() * 200 - 100, delay: (Math.random() * duration * 1 / 2), duration, easing: 'easeInQuad', }); }); } componentWillUnmount() { for (let i = this.animations.length - 1; i >= 0; i--) { this.animations[i].reset(); } this.props.animCb(); } } module.exports = addState(SiphonTick);