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)
使用对象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()获得你的新尺寸并从那里调整.