我正在尝试进行可拖动的导航。代码在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>
任何帮助将不胜感激 感谢