antvis / G

💥 A flexible rendering engine for visualization.

Home Page:https://g.antv.antgroup.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[g]即使动画都停掉,requestAnimationFrame的调用不会停止

coredesign1234 opened this issue · comments

单独在界面上使用canvas,或者做一次canvas的appendChild动作,requestAnimationFrame会不停止地被调用。定位代码如下:

Canvas.prototype.run = function () {
        var _this = this;
        var tick = function () {
            _this.render();
            _this.frameId = _this.requestAnimationFrame(tick);
        };
        tick();
    };

即使界面上什么元素都没有,这个函数也会不停调用

请协助优化一下,这个循环的调用会增加系统整体功耗