diff --git a/client/src/components/animations.jsx b/client/src/components/animations.jsx index 6cc40600..d009fc0a 100644 --- a/client/src/components/animations.jsx +++ b/client/src/components/animations.jsx @@ -6,6 +6,7 @@ const AttackCharge = require('./anims/attack.charge'); const Amplify = require('./anims/amplify'); const Blast = require('./anims/blast'); const banish = require('./anims/banish'); +const Block = require('./anims/block'); const Buff = require('./anims/buff'); const Debuff = require('./anims/debuff'); const Heal = require('./anims/heal'); @@ -92,6 +93,7 @@ function animations(props) { case 'Attack': return ; case 'Amplify': return ; case 'Banish': return banish(construct.id); + case 'Block': return ; case 'Buff': return ; case 'Blast': return ; case 'Debuff': return ; diff --git a/client/src/components/anims/block.jsx b/client/src/components/anims/block.jsx new file mode 100644 index 00000000..37ac6b50 --- /dev/null +++ b/client/src/components/anims/block.jsx @@ -0,0 +1,73 @@ +const preact = require('preact'); +const { Component } = require('preact'); +const anime = require('animejs').default; + +const { TIMES } = require('../../constants'); + +class Block extends Component { + constructor() { + super(); + this.animations = []; + } + + render() { + return ( + + + + + + + + + + ); + } + + componentDidMount() { + this.animations.push(anime({ + targets: ['#block'], + opacity: 1, + + delay: TIMES.TARGET_DELAY_MS, + duration: TIMES.TARGET_DELAY_MS, + })); + + this.animations.push(anime({ + targets: ['feTurbulence', 'feDisplacementMap'], + baseFrequency: 0, + scale: 1, + easing: 'easeOutSine', + + delay: TIMES.TARGET_DELAY_MS, + duration: TIMES.TARGET_DURATION_MS, + })); + } + + // this is necessary because + // skipping / timing / unmounting race conditions + // can cause the animations to cut short, this will ensure the values are reset + // because preact will recycle all these components + componentWillUnmount() { + for (let i = this.animations.length - 1; i >= 0; i--) { + this.animations[i].reset(); + } + } +} + +module.exports = Block;