const preact = require('preact'); const { Component } = require('preact'); const anime = require('animejs').default; const { TIMES } = require('../../constants'); const duration = TIMES.TARGET_DURATION_MS; function laser(dimensions, colour) { const { x, y, length } = dimensions; return ( ); } class Strike extends Component { constructor(props) { super(); this.team = props.team; // this.colour = props.colour; this.colour = props.colour; const coord = [0, 100, 200]; const points = coord.map(pos => ({ x: pos + Math.random() * 80, y: 50 + Math.random() * 100, length: 150 + Math.random() * 100, })); this.charges = points.map(pos => laser(pos, this.colour)); } render() { return ( // {this.charges} {this.charges} ); } componentDidMount() { if (!this.props.team) { anime.set('.skill-anim', { rotate: Math.random() * 180 + 90, }); } else { anime.set('.skill-anim', { rotate: Math.random() * 180 + 270, }); } anime.set('.skill-anim', { translateY: -200, translateX: 0, }); anime.set('#explosion feDisplacementMap', { scale: 1, }); anime({ targets: '.skill-anim', translateY: 0, translateX: 0, loop: false, duration: (duration * 1 / 2), easing: 'easeInQuad', }); anime({ targets: '#explosion feDisplacementMap', scale: 200, loop: false, delay: (duration * 1 / 4), duration, easing: 'easeInQuad', }); } } module.exports = Strike;