我正在使用去抖功能来调整div的大小 - 它工作正常,除了在IE 10和11上,它似乎一直被调用,最终显示滚动条连续打开和div“闪烁”。任何已知的方案?
感谢。
很抱歉 - 这是功能:
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this,
args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
//在背景尺寸更改时调整视频大小
var myResizingFn = debounce(function() {
if ((myPlayer !== null) && ($('#author-pane').length === 0) && (newDimensions !== null)) {
var tWidth = $(window).width();
newDimensions = calculateAspectRatioFit(theWidth, theHeight, tWidth , 10000);
s9.view.size({
width: "100%",
height: newDimensions.height
});
myPlayer.width(newDimensions.width);
myPlayer.height(newDimensions.height);
myPlayer.show();
}
}, 200);
$(window).on('resize', myResizingFn);