ThrottledWidget.js 665 B

1234567
  1. export default class ThrottledWidget extends UI.VBox{constructor(isWebComponent,timeout){super(isWebComponent);this._updateThrottler=new Common.Throttler(timeout===undefined?100:timeout);this._updateWhenVisible=false;}
  2. doUpdate(){return Promise.resolve();}
  3. update(){this._updateWhenVisible=!this.isShowing();if(this._updateWhenVisible){return;}
  4. this._updateThrottler.schedule(innerUpdate.bind(this));function innerUpdate(){if(this.isShowing()){return this.doUpdate();}
  5. this._updateWhenVisible=true;return Promise.resolve();}}
  6. wasShown(){super.wasShown();if(this._updateWhenVisible){this.update();}}}
  7. self.UI=self.UI||{};UI=UI||{};UI.ThrottledWidget=ThrottledWidget;