From 1685e4c2b46a979fa215e527d5621f7617b21e73 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 23 Dec 2016 00:56:44 -0500 Subject: [PATCH] Support transitioned reflect actions --- modules/actions/reflect.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/actions/reflect.js b/modules/actions/reflect.js index 6382f83c8..a28ea7d2d 100644 --- a/modules/actions/reflect.js +++ b/modules/actions/reflect.js @@ -6,6 +6,7 @@ import { import { geoEuclideanDistance, geoExtent, + geoInterp, geoRotate } from '../geo'; @@ -52,7 +53,10 @@ export function actionReflect(reflectIds, projection) { } - var action = function(graph) { + var action = function(graph, t) { + if (t === null || !isFinite(t)) t = 1; + t = Math.min(Math.max(+t, 0), 1); + var nodes = utilGetAllNodes(reflectIds, graph), ssr = getSmallestSurroundingRectangle(graph, nodes); @@ -87,7 +91,8 @@ export function actionReflect(reflectIds, projection) { a * (c[0] - p[0]) + b * (c[1] - p[1]) + p[0], b * (c[0] - p[0]) - a * (c[1] - p[1]) + p[1] ]; - node = node.move(projection.invert(c2)); + var loc2 = projection.invert(c2); + node = node.move(geoInterp(node.loc, loc2, t)); graph = graph.replace(node); } @@ -102,5 +107,8 @@ export function actionReflect(reflectIds, projection) { }; + action.transitionable = true; + + return action; }