From 548b88241f4d7e4789bc2bbc58bd190cfa95005c Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 5 Jul 2019 17:45:54 +1000 Subject: [PATCH] add silence --- client/src/components/animations.jsx | 3 +- client/src/components/anims/silence.jsx | 93 +++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 client/src/components/anims/silence.jsx diff --git a/client/src/components/animations.jsx b/client/src/components/animations.jsx index 0b8669c7..d49b00f6 100644 --- a/client/src/components/animations.jsx +++ b/client/src/components/animations.jsx @@ -30,6 +30,7 @@ const Recharge = require('./anims/recharge'); const Refl = require('./anims/reflect'); const Restrict = require('./anims/restrict'); const Ruin = require('./anims/ruin'); +const Silence = require('./anims/silence'); const Siphon = require('./anims/siphon'); const SiphonTick = require('./anims/siphon.tick'); const Slay = require('./anims/slay'); @@ -136,7 +137,7 @@ function animations(props) { case 'DecayTick': return false; case 'Invert': return ; case 'Purge': return false; - case 'Silence': return false; + case 'Silence': return ; case 'Restrict': return ; // Stun Base diff --git a/client/src/components/anims/silence.jsx b/client/src/components/anims/silence.jsx new file mode 100644 index 00000000..2d50901c --- /dev/null +++ b/client/src/components/anims/silence.jsx @@ -0,0 +1,93 @@ +const preact = require('preact'); +const { Component } = require('preact'); + +const anime = require('animejs').default; + +const { TIMES } = require('../../constants'); + +class Silence extends Component { + constructor() { + super(); + this.animations = []; + } + + render() { + return ( + + + + + + + + + + + + + + + + ); + } + + componentDidMount() { + this.animations.push(anime({ + targets: ['#silence'], + opacity: [ + { value: 1, delay: TIMES.TARGET_DELAY_MS, duration: TIMES.TARGET_DURATION_MS * 0.2 }, + { value: 0, delay: TIMES.TARGET_DURATION_MS * 0.6, duration: TIMES.TARGET_DURATION_MS * 0.2 }, + ], + easing: 'easeInOutSine', + })); + + this.animations.push(anime({ + targets: ['#silence'], + scale: { + value: 1, + delay: TIMES.TARGET_DELAY_MS, + duration: TIMES.TARGET_DURATION_MS * 0.2, + easing: 'easeInExpo', + }, + + delay: TIMES.TARGET_DELAY_MS + TIMES.TARGET_DURATION_MS * 0.1, + duration: TIMES.TARGET_DURATION_MS * 0.2, + easing: 'easeOutSine', + })); + + + this.animations.push(anime({ + targets: ['#sOne'], + d: 'M 124 8 L 8 124', + delay: TIMES.TARGET_DELAY_MS + TIMES.TARGET_DURATION_MS * 0.4, + duration: TIMES.TARGET_DURATION_MS * 0.4, + easing: 'easeOutSine', + })); + + this.animations.push(anime({ + targets: ['#sTwo'], + d: 'M 124 124 L 8 8', + delay: TIMES.TARGET_DELAY_MS + TIMES.TARGET_DURATION_MS * 0.4, + duration: TIMES.TARGET_DURATION_MS * 0.4, + easing: 'easeOutSine', + })); + } + + // 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 = Silence;