Class: ImageCache
Image cache layer.
Allows you to cache HTMLImageElement so you can create them once Lazy loading has been handled.
Properties
cache
• ProtectedReadonly cache: Map(opens in a new tab)<string, HTMLImageElement(opens in a new tab) | () => HTMLImageElement(opens in a new tab)>
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(opens in a new tab)
Get HTMLImageElement by key
Parameters
| Name | Type | Description |
|---|---|---|
key | string | Name of your image |
Returns
undefined | HTMLImageElement(opens in a new tab)
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