JQuery mouseup outside window – possible?
I am trying to accomplish a rudimentary drag. On mousedown the item starts dragging, but not at the same speed as the mouse, so i continue dragging when the mouse is outside the window, but if the mouse is not over the page i can't get mouseup events.
I can see other pages do this so i know it is possible. Appreciate any help.
Edit: eg
Play any video on Vimeo http://vimeo.com/19831216 make sure the window is small enough on your screen with space above it, then drag the video's progress bar left and right, now move the cursor outside the top edge of the window while still dragging left/right - see? Now release mouse button while still outside of the window - dragging ends and video continues playing.
Note: Vimeo has an option to use a flash player or HTML5 player and this is with the html5 pl开发者_StackOverflowayer.
You actually can get the mouseup outside of the browser's window.
It worked for me at least.
$(function(){
$(window).mouseup(function(){
alert('mouse up');
});
});
http://jsfiddle.net/fFeJ6/
Working on Chrome 10 on Ubuntu Maverick.
you can not track mouse events outside the browser window with javascript.
as explained here you can only check if the mouse leaves the window.
You can maybe catch the mouseout event and then call your mouseup function from there:
$(window).mouseout(function() { $(item).mouseup(); });
精彩评论