attack dagger animation test

This commit is contained in:
Mashy 2019-06-14 21:26:22 +10:00
parent b0faf0c33b
commit 13405c9444
3 changed files with 91 additions and 29 deletions

View File

@ -2,6 +2,7 @@ const preact = require('preact');
const { Component } = require('preact');
const anime = require('animejs').default;
const dagger = require('../svgs/dagger');
const { TIMES } = require('../../constants');
const duration = TIMES.START_SKILL;
@ -10,54 +11,72 @@ class Attack extends Component {
constructor(props) {
super();
this.props = props;
this.graphic = (
<g>
<polygon class='blue' points={'0,0 100,50 300,400'}/>
<polygon class='blue' points={'40,170 100,50 160,170'}/>
<polygon class='blue' points={'70,150 100,50 130,150'}/>
</g>
);
}
render() {
return (
<svg
class={`attack-anim-${this.props.id}`}
class={'attack-anim'}
version="1.1"
id="Layer_1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 300 400">
${this.graphic}
{dagger(10, 250, 40, 150)}
{dagger(50, 250, 40, 150)}
{dagger(90, 250, 40, 150)}
{dagger(130, 250, 40, 150)}
{dagger(170, 250, 40, 150)}
{dagger(210, 250, 40, 150)}
{dagger(250, 250, 40, 150)}
</svg>
);
}
componentDidMount() {
let value = '';
if ((!this.props.team && this.props.stage === 'START_SKILL')
|| (this.props.team && this.props.stage === 'END_SKILL')) {
anime.set('.attack-anim', {
rotateX: 0,
let y = 0;
const daggers = document.querySelectorAll('.attack-anim .dagger');
if (this.props.stage === 'START_SKILL') {
anime.set(daggers, {
y: 250,
});
value = '+=250px',
y = -150;
if (!this.props.team) {
anime.set('.attack-anim', {
rotate: 180,
});
} else {
anime.set('.attack-anim', {
rotate: 0,
});
}
}
if ((!this.props.team && this.props.stage === 'END_SKILL')
|| (this.props.team && this.props.stage === 'START_SKILL')) {
anime.set('.attack-anim', {
rotateX: 0,
if (this.props.stage === 'END_SKILL') {
anime.set(daggers, {
y: 400,
});
value = '-=250px',
y = -150;
if (!this.props.team) {
anime.set('.attack-anim', {
rotate: 0,
});
} else {
anime.set('.attack-anim', {
rotate: 180,
});
}
}
anime({
targets: [`.attack-anim-${this.props.id} polygon`],
translateY: {
value,
duration,
},
loop: false,
targets: daggers,
delay: anime.stagger(250, {
start: 250,
grid: [1, 7],
from: 'center',
easing: 'linear',
}),
y,
duration,
easing: 'easeInQuad',
});
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
module.exports = {
TIMES: {
START_SKILL: 700,
END_SKILL: 700,
START_SKILL: 1000,
END_SKILL: 1000,
POST_SKILL: 1000,
DELAY: 150,
},