keep-alive-iframe
Version:
A Vue component for managing iframe lifecycle with keep-alive functionality
59 lines (58 loc) • 1.75 kB
TypeScript
export interface HTMLElementRect {
width: number;
height: number;
top: number;
left: number;
}
export interface IFrameOptions extends HTMLElementRect {
uid: string;
src: string;
zIndex: number;
attrs: Record<string, string | number | boolean>;
onLoaded?: (e: Event) => void;
onError?: (e: Event | string) => void;
keepAlive?: boolean;
container?: HTMLElement;
parentContainer?: HTMLElement;
}
export interface IFrameInstance {
getEl(): HTMLIFrameElement | null;
update(src: string): void;
show(): void;
hide(): void;
resize(rect: HTMLElementRect): void;
destroy(): void;
}
export declare class FrameManager {
private static readonly frameMap;
private static MAX_CACHE_SIZE;
private static updateLastUsed;
private static enforceCacheLimit;
static create(options: IFrameOptions): IFrameInstance;
static destroy(uid: string): void;
static show(uid: string): void;
static hide(uid: string): void;
static resize(uid: string, rect: HTMLElementRect): void;
static update(uid: string, src: string): void;
static get(uid: string): IFrameInstance | undefined;
static clear(): void;
static setMaxCacheSize(size: number): void;
}
export declare class KAliveFrame implements IFrameInstance {
private el;
private readonly options;
private originalRect;
private scrollHandler;
constructor(options: IFrameOptions);
private init;
resize(rect: HTMLElementRect): void;
destroy(): void;
show(): void;
hide(): void;
update(src: string): void;
private setStyle;
private setAttrs;
private addScrollListener;
getEl(): HTMLIFrameElement;
}
export declare function generateId(): string;