谷歌图/表重绘窗口大小调整

Nathan Arthurthecodeparadox提出了一个问题:Google chart redraw/scale on window resize,或许与您遇到的问题类似。

回答者Hemerson Varela给出了该问题的处理方式:

To redraw only when the window resize is completed and avoid multiple triggers, I think is better create an event:

//create trigger to resizeEnd event     
$(window).resize(function() {
    if(this.resizeTO) clearTimeout(this.resizeTO);
    this.resizeTO = setTimeout(function() {
        $(this).trigger('resizeEnd');
    }, 500);
});

//redraw graph when window resize is completed  
$(window).on('resizeEnd', function() {
    drawChart(data);
});

希望本文对你有帮助,欢迎支持JavaScript中文网

原文链接:stackoverflow.com

上一篇:custom-guider
下一篇:在各种浏览器中用JavaScript读取客户端上的文件内容

公众号

欢迎 JavaScript 爱好者