use array index instead of array.shift()
This commit is contained in:
parent
cc007b539a
commit
4a14a79884
@ -328,11 +328,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var textDivIndex = 0;
|
||||||
var renderTextLayer = function canvasRenderTextLayer() {
|
var renderTextLayer = function canvasRenderTextLayer() {
|
||||||
var finished = true;
|
var finished = false;
|
||||||
var textDivs = self.textDivs;
|
var textDivs = self.textDivs;
|
||||||
if (textDivs.length > 0) {
|
if (textDivIndex < textDivs.length) {
|
||||||
var textDiv = textDivs.shift();
|
var textDiv = textDivs[textDivIndex++];
|
||||||
if (textDiv.dataset.textLength > 1) { // avoid div by zero
|
if (textDiv.dataset.textLength > 1) { // avoid div by zero
|
||||||
textLayer.appendChild(textDiv);
|
textLayer.appendChild(textDiv);
|
||||||
// Adjust div width (via letterSpacing) to match canvas text
|
// Adjust div width (via letterSpacing) to match canvas text
|
||||||
@ -341,8 +342,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
((textDiv.dataset.canvasWidth - textDiv.offsetWidth) /
|
((textDiv.dataset.canvasWidth - textDiv.offsetWidth) /
|
||||||
(textDiv.dataset.textLength - 1)) + 'px';
|
(textDiv.dataset.textLength - 1)) + 'px';
|
||||||
}
|
}
|
||||||
finished = false;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
finished = true;
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
var textLayerQueue = this.textLayerQueue;
|
var textLayerQueue = this.textLayerQueue;
|
||||||
|
Loading…
Reference in New Issue
Block a user