UNPKG

@dotglitch/ngx-common

Version:

Angular components and utilities that are commonly used.

47 lines (46 loc) 1.93 kB
import { ElementRef, InjectionToken } from '@angular/core'; import * as i0 from "@angular/core"; export type NgxImageCacheConfig = { /** * Image to use as a placeholder while loading the main image * Recommended to use inlined SVG or a base64 encoded image */ loadingPlaceholder?: string; /** * Image to use as a placeholder where images fail to load * Recommended to use inlined SVG or a base64 encoded image */ brokenPlaceholder?: string; }; export declare const NGX_IMAGE_CACHE_CONFIG: InjectionToken<NgxImageCacheConfig>; export type NgxImageCacheConfiguration = { /** * Max age to cache an image in milliseconds. * If set to `0` or a negative number, images will never expire. */ maxAge: number; /** * Set to `false` to disable memory caching for the image * If both `cacheInMemory` and `cacheInIndexedDB` are false, * no caching will happen. (You'll still get the loader) */ cacheInMemory: boolean; /** * Set to `false` to disable indexedDB caching for the image * If both `cacheInMemory` and `cacheInIndexedDB` are false, * no caching will happen. (You'll still get the loader) */ cacheInIndexedDB: boolean; }; export declare class NgxImageCacheDirective { private readonly element; private readonly cacheConfig; url: string; configuration: NgxImageCacheConfiguration; private get el(); constructor(element: ElementRef, cacheConfig: NgxImageCacheConfig); ngOnChanges(): void; getCachedImage(): Promise<void>; static ɵfac: i0.ɵɵFactoryDeclaration<NgxImageCacheDirective, [null, { optional: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration<NgxImageCacheDirective, "img[ngx-cache]", never, { "url": { "alias": "source"; "required": false; }; "configuration": { "alias": "ngx-cache-config"; "required": false; }; }, {}, never, never, true, never>; }