UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 1.13 kB
import*as UI from"../../ui/legacy/legacy.js";import animationScreenshotPopoverStyles from"./animationScreenshotPopover.css.js";export class AnimationScreenshotPopover extends UI.Widget.VBox{#e;#t;#s;#r;#i;#n;constructor(e){super(!0),console.assert(e.length>0),this.contentElement.classList.add("animation-screenshot-popover"),this.#e=e;for(const t of e)this.contentElement.appendChild(t),t.style.display="none";this.#t=0,this.#s=0,this.#e[0].style.display="block",this.#r=this.contentElement.createChild("div","animation-progress")}wasShown(){this.#t=this.contentElement.window().requestAnimationFrame(this.changeFrame.bind(this)),this.registerCSSFiles([animationScreenshotPopoverStyles])}willHide(){this.contentElement.window().cancelAnimationFrame(this.#t),this.#n=void 0}changeFrame(){if(this.#t=this.contentElement.window().requestAnimationFrame(this.changeFrame.bind(this)),this.#n)return void this.#n--;if(this.#i=!this.#i,!this.#i)return;const e=this.#e.length;this.#e[this.#s%e].style.display="none",this.#s++,this.#e[this.#s%e].style.display="block",this.#s%e==e-1&&(this.#n=50),this.#r.style.width=(this.#s%e+1)/e*100+"%"}}