An image component that uses a cross-browser strategy to decode images off the main thread before rendering to canvas. This standardizes behavior across Chrome, Firefox, and Safari to prevent main thread blocking.
💡 Implements the strategy from fastDrawImage by @myshov and his article on PerfPlanet.
| Name | Privacy | Type | Default | Description | Inherited From |
|---|---|---|---|---|---|
src |
string |
'' |
The src of the image to display. | ||
width |
number |
150 |
The width of the canvas. | ||
height |
number |
150 |
The height of the canvas. | ||
alt |
string |
'' |
The alternative text for the image. |
| Name | Field | Inherited From |
|---|---|---|
src |
src | |
width |
width | |
height |
height | |
alt |
alt |
Private API
| Name | Privacy | Type | Default | Description | Inherited From |
|---|---|---|---|---|---|
__abortController |
private | AbortController | undefined |
|||
__canvas |
private | HTMLCanvasElement | undefined |
|||
_errorTpl |
private |
| Name | Privacy | Description | Parameters | Return | Inherited From |
|---|---|---|---|---|---|
_drawImage |
private | ||||
_loadImage |
private | src: string, signal: AbortSignal |
Promise<ImageBitmap> |
| Kind | Name | Declaration | Module | Package |
|---|---|---|---|---|
js |
AsyncDecodedImageCanvas |
AsyncDecodedImageCanvas | src/AsyncDecodedImageCanvas.ts |
| Kind | Name | Declaration | Module | Package |
|---|---|---|---|---|
js |
AsyncDecodedImageCanvas |
AsyncDecodedImageCanvas | ./AsyncDecodedImageCanvas.js |
| Kind | Name | Declaration | Module | Package |
|---|---|---|---|---|
custom-element-definition |
async-decoded-image-canvas |
AsyncDecodedImageCanvas | /src/AsyncDecodedImageCanvas.js |
| Name | Description | Type |
|---|---|---|
styles |
| Kind | Name | Declaration | Module | Package |
|---|---|---|---|---|
js |
styles |
styles | src/styles/async-decoded-image-canvas-styles.css.ts |