fixed parry, added all skills to anims callback

This commit is contained in:
Mashy
2019-07-02 23:11:48 +10:00
parent 8dd3a923ec
commit 3b115f82a4
3 changed files with 139 additions and 41 deletions
+5 -5
View File
@@ -43,8 +43,8 @@ class Parry extends Component {
this.animations.push(anime({
targets: ['#parry'],
opacity: [
{ value: 1, delay: TIMES.TARGET_FADE_IN_DELAY, duration: TIMES.TARGET_FADE_IN_DURATION },
{ value: 0, delay: TIMES.TARGET_FADE_OUT_DELAY, duration: TIMES.FADE_OUT_DURATION },
{ 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.3 },
],
easing: 'easeInOutSine',
}));
@@ -52,7 +52,7 @@ class Parry extends Component {
this.animations.push(anime({
targets: ['#parry'],
rotateX: 180,
delay: TIMES.TARGET_FADE_IN_DELAY * 3,
delay: TIMES.TARGET_DELAY_MS,
duration: TIMES.TARGET_DURATION_MS / 2,
easing: 'easeOutSine',
}));
@@ -64,8 +64,8 @@ class Parry extends Component {
numOctaves: 5,
easing: 'easeOutSine',
delay: TIMES.TARGET_FADE_IN_DELAY,
duration: TIMES.RESOLUTION_TOTAL_MS,
delay: TIMES.TARGET_DELAY_MS,
duration: TIMES.TARGET_DURATION_MS,
}));
}
+76
View File
@@ -0,0 +1,76 @@
const preact = require('preact');
const { Component } = require('preact');
const anime = require('animejs').default;
const { TIMES } = require('../../constants');
class Purify extends Component {
constructor() {
super();
this.animations = [];
}
render({ team }) {
return (
<svg
class='skill-animation red'
version="1.1"
id="purify"
xmlns="http://www.w3.org/2000/svg"
style={{ transform: team ? 'rotate3d(1, 0, 0, 180deg)' : '' }}
viewBox="0 0 256 256">
<filter id='purifyFilter'>
<feTurbulence type="turbulence" baseFrequency="0" numOctaves="1" result="turbulence"></feTurbulence>
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="1" xChannelSelector="R" yChannelSelector="G"></feDisplacementMap>
</filter>
<polyline
points='128,168 80,240 176,240 128,168'
style={{ filter: 'url("#purifyFilter")' }}
/>
<polyline
points='176,240 212,216 128,96 44,216 80,240'
style={{ filter: 'url("#purifyFilter")' }}
/>
<polyline
points='212,216 248,192 128,24 8,192 44,216'
style={{ filter: 'url("#purifyFilter")' }}
/>
</svg>
);
}
componentDidMount() {
this.animations.push(anime({
targets: ['#purify'],
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.3 },
],
easing: 'easeInOutSine',
}));
this.animations.push(anime({
targets: ['#purifyFilter feTurbulence', ' #purifyFilter feDisplacementMap'],
baseFrequency: 2,
scale: 10,
numOctaves: 5,
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 = Purify;