import { UI } from './UI'; import { PageFlip } from '../PageFlip'; import { FlipSetting } from '../Settings'; /** * UI for HTML mode */ export class HTMLUI extends UI { private items: NodeListOf | HTMLElement[]; constructor( inBlock: HTMLElement, app: PageFlip, setting: FlipSetting, items: NodeListOf | HTMLElement[] ) { super(inBlock, app, setting); // Second wrapper to HTML page this.wrapper.insertAdjacentHTML('afterbegin', '
'); this.distElement = inBlock.querySelector('.stf__block'); this.items = items; for (const item of items) { this.distElement.appendChild(item); } this.setHandlers(); } public clear(): void { for (const item of this.items) { this.parentElement.appendChild(item); } } /** * Update page list from HTMLElements * * @param {(NodeListOf|HTMLElement[])} items - List of pages as HTML Element */ public updateItems(items: NodeListOf | HTMLElement[]): void { this.removeHandlers(); this.distElement.innerHTML = ''; for (const item of items) { this.distElement.appendChild(item); } this.items = items; this.setHandlers(); } public update(): void { this.app.getRender().update(); } }