发布于 5年前

如何监听浏览器窗口变化,改变宽高


在ready方法中
    function callbackOpenseadragon(){
        console.log('1111111111111111111111111111');
        $('#pathologyID').css('height',$('.navigator').height());
        $('#pathologyID').css('width',$('.navigator').width());
        $('#pathologyID').css('top',$('.navigator').height()+50);
    }
    function windowResizeEvent(callbackOpenseadragon) {
        var firstFire = null;
        window.onresize = function () {
            console.log('aaaa');
            if(firstFire === null) {
                firstFire = setTimeout(function() {
                    firstFire = null;
                    callbackOpenseadragon;
                }, 100);
            }
        }
    }
    windowResizeEvent();
    callbackOpenseadragon方法没有被用到,windowResizeEvent执行了,应该怎么改?

解决方案

function windowResizeEvent() {
        var firstFire = null;
        window.onresize = function () {
            console.log('aaaa');
            if(firstFire === null) {
                firstFire = setTimeout(function() {
                    firstFire = null;
                    callbackOpenseadragon();
                }, 100);
            }
        }
    }
©2020 edoou.com   京ICP备16001874号-3