From 4a14a798845e42e946f41da89a4bdc6ceab4a08d Mon Sep 17 00:00:00 2001 From: Adil Allawi Date: Thu, 15 Dec 2011 10:08:50 +0000 Subject: [PATCH] use array index instead of array.shift() --- src/canvas.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/canvas.js b/src/canvas.js index fbebc0aa2..38b33d19d 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -328,11 +328,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { return; var self = this; + var textDivIndex = 0; var renderTextLayer = function canvasRenderTextLayer() { - var finished = true; + var finished = false; var textDivs = self.textDivs; - if (textDivs.length > 0) { - var textDiv = textDivs.shift(); + if (textDivIndex < textDivs.length) { + var textDiv = textDivs[textDivIndex++]; if (textDiv.dataset.textLength > 1) { // avoid div by zero textLayer.appendChild(textDiv); // Adjust div width (via letterSpacing) to match canvas text @@ -341,8 +342,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { ((textDiv.dataset.canvasWidth - textDiv.offsetWidth) / (textDiv.dataset.textLength - 1)) + 'px'; } - finished = false; } + else + finished = true; return finished; } var textLayerQueue = this.textLayerQueue;