Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 player.

like image 715
hooleyhoop Avatar asked Mar 24 '11 11:03

hooleyhoop


3 Answers

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.

like image 85
thwd Avatar answered Oct 01 '22 07:10

thwd


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.

like image 23
felixsigl Avatar answered Oct 01 '22 08:10

felixsigl


You can maybe catch the mouseout event and then call your mouseup function from there:

$(window).mouseout(function() { $(item).mouseup(); });
like image 39
Richard Dalton Avatar answered Oct 01 '22 06:10

Richard Dalton