これらのdivの1つをスクロールしたときにDIV
、イベントを発生させたい4つがあります。scroll
これは以下のコードです。
$('#div1, #div2, #div3, #div4').scroll(function() {
alert('...');
});
Firefox / Chromeでは、これは高速に実行されます。ただし、Internet Explorerでは、これは非常に遅いため、実際にはdivをスクロールできません。
最新バージョンのJQuery(v.1.4.1)を使用しています。
質問:上記のコードを実行するためのより効果的な方法はありますか?もしそうなら、どのように?
更新:質問されたので、コード全体を以下に含めました:
$('#div1, #div2, #div3, #div4').scroll(function() {
/* find the closest (hlisting) home listing to the middle of the scrollwindow */
var scrollElemPos = activeHomeDiv.offset();
var newHighlightDiv = $(document.elementFromPoint(
scrollElemPos.left + activeHomeDiv.width() / 2,
scrollElemPos.top + activeHomeDiv.height() / 2)
).closest('.hlisting');
if(newHighlightDiv.is(".HighlightRow")) return;
$('.HighlightRow').removeClass("HighlightRow");
newHighlightDiv.addClass('HighlightRow');
/* change the map marker icon to denote the currently focused on home */
var activeHomeID = newHighlightDiv.attr("id");
if (activeHomeMarkerID) {
// unset the old active house marker to a normal icon
map.markers[activeHomeMarkerID].setIcon('http://example.com/images/house-icon.png');
}
activeHomeMarkerID = activeHomeID.substring(4); // set the new active marker id
map.markers[activeHomeMarkerID].setIcon('http://example.com/images/house-icon-active.png');
});
更新2:
だから私は以下のタイマーオプションを実装しました、そしてIEではそれはまだ同じくらい遅いです。他のアイデアはありますか?