diff --git a/client/src/components/animations.jsx b/client/src/components/animations.jsx index a7cb291e..564070fc 100644 --- a/client/src/components/animations.jsx +++ b/client/src/components/animations.jsx @@ -90,17 +90,8 @@ function animations(props) { : otherTeamIds.findIndex(c => c === resolution.target.id); const x = j - i; - if (avatarAnimation !== resolution.id) { - console.log(avatarAnimation); - setAvatarAnimation(resolution.id); - anime({ - targets: [document.getElementById(construct.id)], - translateY: y * 200, - translateX: x * 200, - easing: 'easeInOutElastic', - direction: 'alternate', - duration: TIMES.SOURCE_DURATION_MS, - }); + if (avatarAnimation.id !== resolution.id) { + setAvatarAnimation({ id: resolution.id, animTargetId: construct.id, x, y }); } } const targetTeam = targetIsPlayer ? playerTeamIds : otherTeamIds; diff --git a/client/src/components/construct.jsx b/client/src/components/construct.jsx index 2a16c0ae..030c7583 100644 --- a/client/src/components/construct.jsx +++ b/client/src/components/construct.jsx @@ -1,9 +1,10 @@ const preact = require('preact'); const { Component } = require('preact'); const { connect } = require('preact-redux'); - const anime = require('animejs').default; +const { TIMES } = require('../constants'); + const genAvatar = name => { let hash = 0; if (name.length === 0) return hash; @@ -47,6 +48,12 @@ const addState = connect( ); class ConstructAvatar extends Component { + constructor() { + super(); + this.animId = 0; + this.animations = []; + } + render() { return (
{ if (err) return console.error(err); + store.dispatch(actions.setAvatarAnimation({ id: -1 })); store.dispatch(actions.setResolution(null)); // stop skipping resolutions store.dispatch(actions.setSkip(false)); diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index f2cc8cae..abd7ad03 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -15,7 +15,7 @@ module.exports = { activeConstruct: createReducer(null, 'SET_ACTIVE_CONSTRUCT'), activeItem: createReducer(null, 'SET_ACTIVE_VAR'), activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'), - avatarAnimation: createReducer(null, 'SET_AVATAR_ANIMATION'), + avatarAnimation: createReducer({ id: -1 }, 'SET_AVATAR_ANIMATION'), combiner: createReducer([null, null, null], 'SET_COMBINER'), constructs: createReducer([], 'SET_CONSTRUCTS'), constructDeleteId: createReducer(null, 'SET_CONSTRUCT_DELETE_ID'),