在浏览器窗口调整大小时刷新一些jquery

sar*_*585 1 browser jquery resize refresh

我正在使用第三方旋转木马,它可以动态增加直线宽度和高度样式.当浏览器大小减小时,该站点使用媒体查询来调整轮播容器的大小.我的问题是必须刷新页面才能进入媒体查询.所以我可以在调整大小时刷新jQuery函数,以便重新计算其宽度/高度吗?

这是jQuery:

    <script type="text/javascript">

    $(document).ready(function () {

    $("#carousel").featureCarousel({
    // include options like this:
    // (use quotes only for string values, and no trailing comma after last option)
    carouselSpeed:700,
    smallFeatureWidth:0.8, smallFeatureHeight:0.8, sidePadding:0, topPadding:0
    });
    });
    </script>
Run Code Online (Sandbox Code Playgroud)

fai*_*ino 5

使用对象resize()上的window函数:

$(window).resize(function(){
    $("#carousel").featureCarousel({
        // include options like this:
        // (use quotes only for string values, and no trailing comma after last option)
        carouselSpeed:700,
        smallFeatureWidth:0.8, smallFeatureHeight:0.8, sidePadding:0, topPadding:0
    });
});
Run Code Online (Sandbox Code Playgroud)

然后你可以使用$(window).height()$(window).width()获得你的新尺寸并从那里调整.