From 089ff4e27479dc8305f9cd67ce85b7bf4503c3f3 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 8 Jul 2019 20:58:27 +1000 Subject: [PATCH] smooth as butter --- client/src/components/construct.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/components/construct.jsx b/client/src/components/construct.jsx index 030c7583..b70f0161 100644 --- a/client/src/components/construct.jsx +++ b/client/src/components/construct.jsx @@ -65,13 +65,14 @@ class ConstructAvatar extends Component { } componentDidMount() { - animateConstruct(this.props.id); + this.idle = animateConstruct(this.props.id); } componentWillReceiveProps(nextProps) { if (nextProps.avatarAnimation.id !== this.animId && nextProps.avatarAnimation.animTargetId === this.props.id) { this.animId = nextProps.avatarAnimation.id; - anime({ + this.idle.pause(); + const anim = anime({ targets: [document.getElementById(this.props.id)], translateY: nextProps.avatarAnimation.y * 200, translateX: nextProps.avatarAnimation.x * 200, @@ -79,6 +80,7 @@ class ConstructAvatar extends Component { direction: 'alternate', duration: TIMES.SOURCE_DURATION_MS, }); + anim.finished.then(this.idle.play); } // console.log(this.props); // console.log(nextProps);