From 6b09da380da6b7e0ea1f1a23ca070157458a29cf Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Fri, 11 Jan 2013 16:56:28 -0500 Subject: [PATCH] only getComputedTextLength() once --- js/id/svg/lines.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/id/svg/lines.js b/js/id/svg/lines.js index a183f4aea..713432b8b 100644 --- a/js/id/svg/lines.js +++ b/js/id/svg/lines.js @@ -1,10 +1,14 @@ iD.svg.Lines = function() { - return function(surface, graph, entities, filter, projection) { - var arrowtext = '►\u3000\u3000', - arrow = surface.append('text').text(arrowtext), - alength = arrow.node().getComputedTextLength(); - arrow.remove(); + var arrowtext = '►\u3000\u3000', + alength; + + return function(surface, graph, entities, filter, projection) { + if (!alength) { + var arrow = surface.append('text').text(arrowtext); + alength = arrow.node().getComputedTextLength(); + arrow.remove(); + } var lines = [];