0

スクロール可能な div に mousemove イベントがあります。Firefox は、スクロール スライダーをドラッグしているときに mousemove イベントを発生させる唯一の主要なブラウザーです。それを取り除く方法を知っていますか?

HTML

<div id="outer">
    <div id="inner">
    </div>
</div>

<div id="reporter1"></div>
<div id="reporter2"></div>

JS

$("#outer").on("scroll", function (event) {
    $("#reporter1").text("scroll");
});

$("#outer").on("mousemove", function (event) {
    $("#reporter2").text("mousemove");
});

setInterval(function () {
    $("#reporter1").text("");
    $("#reporter2").text("");
}, 500);

jsfiddleを参照してください。

4

1 に答える 1

0

off()イベント ハンドラーと単純なタイマーを使用できます。

var timer;
rebind();

$('#outer').on('scroll', function(){
     clearTimeout(timer);
     $('#outer').off('mousemove');
     timer = setTimeout(rebind, 500);
});

function rebind() {
     $('#outer').on('mousemove',function() {
             $("#reporter2").text("mousemove");
     });
}
于 2013-08-27T13:15:38.747 に答える