@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 572 B
JavaScript
import*as Common from"../../core/common/common.js";import{VBox}from"./Widget.js";export class ThrottledWidget extends VBox{updateThrottler;updateWhenVisible;constructor(e,t){super(e),this.updateThrottler=new Common.Throttler.Throttler(void 0===t?100:t),this.updateWhenVisible=!1}doUpdate(){return Promise.resolve()}update(){this.updateWhenVisible=!this.isShowing(),this.updateWhenVisible||this.updateThrottler.schedule((()=>this.isShowing()?this.doUpdate():(this.updateWhenVisible=!0,Promise.resolve())))}wasShown(){super.wasShown(),this.updateWhenVisible&&this.update()}}