From 6f38d694aceb0268d1e751604d1d44bc5134cd7e Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 1 Jul 2019 17:03:45 +1000 Subject: [PATCH] red block --- client/src/components/anims/red.block.jsx | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 client/src/components/anims/red.block.jsx diff --git a/client/src/components/anims/red.block.jsx b/client/src/components/anims/red.block.jsx new file mode 100644 index 00000000..812b32cb --- /dev/null +++ b/client/src/components/anims/red.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: ['#blockFilter feTurbulence', ' #blockFilter 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;