Class: ImageCache
Image cache layer
Allows to cache HTMLImageElement to create them once Lazy loading handled
Properties
cache
• Protected Readonly cache: Map<string, HTMLImageElement | () => HTMLImageElement>
Cache map
Methods
register
▸ register(key, src, lazy?): this
Register an image in the cache
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
Name of your image |
src |
string |
Source url/path of your image |
lazy? |
boolean |
Should lazy load the image (default: false) |
Returns
this
get
▸ get(key): undefined | HTMLImageElement
Get HTMLImageElement by key
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
Name of your image |
Returns
undefined | HTMLImageElement
has
▸ has(key): boolean
Check if an image exists by key
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
Name of your image |
Returns
boolean
loaded
▸ loaded(key): boolean
Check if an image has been loaded
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
Name of your image |
Returns
boolean
Related Topics