Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
removeChildAt(index)
{
const child = this.getChildAt(index);
// ensure child transform will be recalculated..
child.parent = null;
child.transform._parentID = -1;
removeItems(this.children, index, 1);
// ensure bounds will be recalculated
this._boundsID++;
// TODO - lets either do all callbacks or all events.. not both!
this.onChildrenChange(index);
child.emit('removed', this);
this.emit('childRemoved', child, this, index);
return child;
}
removeChildAt(index)
{
const child = this.getChildAt(index);
// ensure child transform will be recalculated..
child.parent = null;
child.transform._parentID = -1;
removeItems(this.children, index, 1);
// ensure bounds will be recalculated
this._boundsID++;
// TODO - lets either do all callbacks or all events.. not both!
this.onChildrenChange(index);
child.emit('removed', this);
this.emit('childRemoved', child, this, index);
return child;
}
setChildIndex(child, index)
{
if (index < 0 || index >= this.children.length)
{
throw new Error(`The index ${index} supplied is out of bounds ${this.children.length}`);
}
const currentIndex = this.getChildIndex(child);
removeItems(this.children, currentIndex, 1); // remove from old position
this.children.splice(index, 0, child); // add at new position
this.onChildrenChange(index);
}
setChildIndex(child, index)
{
if (index < 0 || index >= this.children.length)
{
throw new Error(`The index ${index} supplied is out of bounds ${this.children.length}`);
}
const currentIndex = this.getChildIndex(child);
removeItems(this.children, currentIndex, 1); // remove from old position
this.children.splice(index, 0, child); // add at new position
this.onChildrenChange(index);
}
let div = this.div;
div.style.left = `${rect.left}px`;
div.style.top = `${rect.top}px`;
div.style.width = `${this.renderer.width}px`;
div.style.height = `${this.renderer.height}px`;
for (let i = 0; i < this.children.length; i++)
{
const child = this.children[i];
if (child.renderId !== this.renderId)
{
child._accessibleActive = false;
removeItems(this.children, i, 1);
this.div.removeChild(child._accessibleDiv);
this.pool.push(child._accessibleDiv);
child._accessibleDiv = null;
i--;
if (this.children.length === 0)
{
this.deactivate();
}
}
else
{
// map div to display..
div = child._accessibleDiv;
let hitArea = child.hitArea;
chars.push({
texture: charData.texture,
line,
charCode,
position: new Point(pos.x + charData.xOffset + (this._letterSpacing / 2), pos.y + charData.yOffset),
});
pos.x += charData.xAdvance + this._letterSpacing;
lastLineWidth = pos.x;
maxLineHeight = Math.max(maxLineHeight, (charData.yOffset + charData.texture.height));
prevCharCode = charCode;
if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth)
{
++spacesRemoved;
removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos);
i = lastBreakPos;
lastBreakPos = -1;
lineWidths.push(lastBreakWidth);
maxLineWidth = Math.max(maxLineWidth, lastBreakWidth);
line++;
pos.x = 0;
pos.y += data.lineHeight;
prevCharCode = null;
}
}
const lastChar = text.charAt(text.length - 1);
if (lastChar !== '\r' && lastChar !== '\n')
if (texture._glTextures[this.CONTEXT_UID])
{
this.unbind(texture);
gl.deleteTexture(texture._glTextures[this.CONTEXT_UID].texture);
texture.off('dispose', this.destroyTexture, this);
delete texture._glTextures[this.CONTEXT_UID];
if (!skipRemove)
{
const i = this.managedTextures.indexOf(texture);
if (i !== -1)
{
removeItems(this.managedTextures, i, 1);
}
}
}
}
chars.push({
texture: charData.texture,
line,
charCode,
position: new Point(pos.x + charData.xOffset + (this._letterSpacing / 2), pos.y + charData.yOffset),
});
pos.x += charData.xAdvance + this._letterSpacing;
lastLineWidth = pos.x;
maxLineHeight = Math.max(maxLineHeight, (charData.yOffset + charData.texture.height));
prevCharCode = charCode;
if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth)
{
++spacesRemoved;
removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos);
i = lastBreakPos;
lastBreakPos = -1;
lineWidths.push(lastBreakWidth);
maxLineWidth = Math.max(maxLineWidth, lastBreakWidth);
line++;
pos.x = 0;
pos.y += data.lineHeight;
prevCharCode = null;
}
}
const lastChar = text.charAt(text.length - 1);
if (lastChar !== '\r' && lastChar !== '\n')