From dbd06c2053f4851335f488d2f27eac65fb39dc42 Mon Sep 17 00:00:00 2001 From: Mashy Date: Sat, 26 Oct 2019 13:33:58 +1000 Subject: [PATCH] improved wiggle --- client/src/components/anims/wiggle.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/components/anims/wiggle.jsx b/client/src/components/anims/wiggle.jsx index a9615181..e071450b 100644 --- a/client/src/components/anims/wiggle.jsx +++ b/client/src/components/anims/wiggle.jsx @@ -6,17 +6,18 @@ function wiggle(id, idle) { const x = window.innerWidth * 0.01 * (Math.round(Math.random()) ? Math.random() : -Math.random()); const y = window.innerHeight * 0.01 * (Math.round(Math.random()) ? Math.random() : -Math.random()); + const originalX = parseFloat(idle.animations[0].currentValue); + const originalY = parseFloat(idle.animations[1].currentValue); // console.log(x, y); return anime({ targets: target, - rotate: 0, - translateX: [x, -x, 0], - translateY: [y, -y, 0], + translateX: [originalX + x, originalX - x, originalX], + translateY: [originalY + y, originalY - y, originalY], duration, easing: 'easeInOutSine', // direction: 'alternate', begin: idle.pause, - complete: idle.restart, + complete: idle.play, }); }