1

我正在尝试制作可拖动的导航。该代码在 chrome 中运行良好,但由于某种原因,该代码在 Firefox 中无法运行:

<script type="text/javascript">

$(document).ready(function() {

$('img').on('dragstart', function(event) { event.preventDefault(); });

$('body').mousemove(function (event) {
//button clicked
if (event.which)
    {
    //there is a previous movement
    if (window.moveEvent)
        {
        //difference in position since last time
        var xDiff = event.screenX - window.moveEvent.screenX;
        var yDiff = event.screenY - window.moveEvent.screenY;

        //Move the scroll bar by the same amount as we moved the mouse
        $('body').scrollTop($('body').scrollTop() - yDiff);
        $('body').scrollLeft($('body').scrollLeft() - xDiff);

        //$('body').addClass('grabbing');
        event.preventDefault();
        }
    window.moveEvent = event; //store for next time
    }
else
    {
    //$('body').removeClass('grabbing');
    window.moveEvent = false; //wipe the last one
    }
});
//.mouseup(function () {$('body').addClass('grabbing');});
});
</script>

任何帮助将不胜感激谢谢

4

0 回答 0