私はちょうどあなたを助けるかもしれない別の問題を発見しました.
私はjQueryを使用しており、ボディに追加されたdivを再配置する関数を呼び出すwindow.resizeイベントがあります。
追加された div の LEFT css プロパティを設定すると、window.resize イベントが NO GOOD REASON のトリガーを取得します。
無限ループが発生し、window.resize が何度もトリガーされます。
修正なしのコード:
$(window).resize(function(){
var onResize = function(){
//The method which alter some css properties triggers
//window.resize again and it ends in an infinite loop
someMethod();
}
window.clearTimeout(resizeTimeout);
resizeTimeout = window.setTimeout(onResize, 10);
});
解決:
var winWidth = $(window).width(),
winHeight = $(window).height();
$(window).resize(function(){
var onResize = function(){
//The method which alter some css properties triggers
//window.resize again and it ends in an infinite loop
someMethod();
}
//New height and width
var winNewWidth = $(window).width(),
winNewHeight = $(window).height();
// compare the new height and width with old one
if(winWidth!=winNewWidth || winHeight!=winNewHeight){
window.clearTimeout(resizeTimeout);
resizeTimeout = window.setTimeout(onResize, 10);
}
//Update the width and height
winWidth = winNewWidth;
winHeight = winNewHeight;
});
したがって、基本的には、高さまたは幅が変更されたかどうかを確認します(実際にウィンドウのサイズを変更した場合にのみ発生します)。