画面更新要求が発生する DOM elementの操作実行用

Format
JavaScript
Post date
2016-11-29 19:18
Publication Period
Unlimited
  1. class RenderLoop {
  2. constructor() {
  3. this.renderQue = new Queue();
  4. this.rendering = null; // loop処理呼び出し済み判定用
  5. }
  6. // 描画用callback関数登録要求
  7. // 引数のcallbackを1回呼び出します
  8. // callback: function callback(time)
  9. requestRenderFunc(callback) {
  10. console.log('Request render function = ' + (callback ? callback.name : 'null'));
  11. if (null != callback){
  12. this.renderQue.enqueue(callback);
  13. // 描画loop
  14. (function renderloop(time) {
  15. if (0 < this.renderQue.size()) {
  16. this.renderQue.dequeue()(time);
  17. console.log('render func size=' + this.renderQue.size());
  18. requestAnimationFrame(renderloop.bind(this));
  19. }
  20. }.call(this,window.performance.now()));
  21. }
  22. }
  23. }
Download Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text