From bc82b3ba6f3a665c061afd3405a0be20cd2ec15d Mon Sep 17 00:00:00 2001 From: huarui Date: Wed, 25 Jul 2018 11:59:23 -0700 Subject: [PATCH] refactor to reduce loc --- src/core/core.interaction.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/core/core.interaction.js b/src/core/core.interaction.js index 3e4bc3e027b..59474a5b32b 100644 --- a/src/core/core.interaction.js +++ b/src/core/core.interaction.js @@ -308,11 +308,7 @@ module.exports = { // sort by distance Object.keys(byIndex).forEach(function(key) { byIndex[key].sort(function(a, b) { - var centerA = a.getCenterPoint(); - var centerB = b.getCenterPoint(); - var distanceA = distanceMetric(position, centerA); - var distanceB = distanceMetric(position, centerB); - return distanceA - distanceB; + return distanceMetric(position, a.getCenterPoint()) - distanceMetric(position, b.getCenterPoint()); }); });