From 9e7d902339755b37ba228f837700c3886a337aa2 Mon Sep 17 00:00:00 2001 From: Saivan Date: Fri, 29 Jun 2018 09:18:54 +1000 Subject: Added a potential fix for the problem --- src/matrix.js | 1 + src/runner.js | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/matrix.js b/src/matrix.js index 05e9c7d..4396816 100644 --- a/src/matrix.js +++ b/src/matrix.js @@ -129,6 +129,7 @@ SVG.Matrix = SVG.invent({ var lam = (a * c + b * d) / determinant var sy = ((c * sx) / (lam * a - b)) || ((d * sx) / (lam * b + a)) + // Use the translations let tx = e - cx + cx * ct * sx + cy * (lam * ct * sx - st * sy) let ty = f - cy + cx * st * sx + cy * (lam * st * sx + ct * sy) diff --git a/src/runner.js b/src/runner.js index 963f31b..4c9dda2 100644 --- a/src/runner.js +++ b/src/runner.js @@ -700,6 +700,13 @@ SVG.extend(SVG.Runner, { } // FIXME: correct the rotation so that it takes the shortest path + // GIVE ME (rCurrent) (rTarget) - to store the current/target angle + const possibilities = [rTarget - 360, rTarget, rTarget + 360] + const distances = possibilities.map( a => Math.abs(a - rCurrent) ) + const shortest = Math.min(...distances) + const index = distances.indexOf(shortest) + const target = possibilities[index] + morpher.from(startMatrix) }, function (pos) { -- cgit v1.2.3