@pixi/text-html
Advanced tools
Comparing version 7.2.0-beta to 7.2.0-beta.2
@@ -54,2 +54,3 @@ import { Rectangle } from '@pixi/core'; | ||
private _image; | ||
private _loadImage; | ||
private _resolution; | ||
@@ -56,0 +57,0 @@ private _text; |
@@ -49,2 +49,3 @@ 'use strict'; | ||
this._image = image; | ||
this._loadImage = new Image(); | ||
this._autoResolution = _HTMLText.defaultAutoResolution; | ||
@@ -86,3 +87,3 @@ this._resolution = _HTMLText.defaultResolution ?? core.settings.RESOLUTION; | ||
async updateText(respectDirty = true) { | ||
const { style, _image: image } = this; | ||
const { style, _image: image, _loadImage: loadImage } = this; | ||
if (this.localStyleID !== style.styleID) { | ||
@@ -96,10 +97,13 @@ this.dirty = true; | ||
const { width, height } = this.measureText(); | ||
image.width = Math.ceil(Math.max(1, width)); | ||
image.height = Math.ceil(Math.max(1, height)); | ||
image.width = loadImage.width = Math.ceil(Math.max(1, width)); | ||
image.height = loadImage.height = Math.ceil(Math.max(1, height)); | ||
if (!this._loading) { | ||
this._loading = true; | ||
await new Promise((resolve) => { | ||
image.onload = async () => { | ||
loadImage.onload = async () => { | ||
await style.onBeforeDraw(); | ||
this._loading = false; | ||
image.src = loadImage.src; | ||
loadImage.onload = null; | ||
loadImage.src = ""; | ||
this.updateTexture(); | ||
@@ -109,3 +113,3 @@ resolve(); | ||
const svgURL = new XMLSerializer().serializeToString(this._svgRoot); | ||
image.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(svgURL)}`; | ||
loadImage.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(svgURL)}`; | ||
}); | ||
@@ -178,3 +182,5 @@ } | ||
this._styleElement = forceClear; | ||
this._image.onload = null; | ||
this._loadImage.src = ""; | ||
this._loadImage.onload = null; | ||
this._loadImage = forceClear; | ||
this._image.src = ""; | ||
@@ -181,0 +187,0 @@ this._image = forceClear; |
{ | ||
"name": "@pixi/text-html", | ||
"version": "7.2.0-beta", | ||
"version": "7.2.0-beta.2", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "module": "lib/index.mjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152681
51896
1336