How to detect whether touch slide is taking me out of browser window on tablets?

162 views Asked by At

I have an application where it can be made full screen by clicking on maximize button and to restore it back, I have a logic to detect, if user moves out of application window, show message with a link to restore window. Its pretty similar to F11 functionality of browser.

Javascript code to detect movement of mouse outside of application browser window is working fine for desktop clients but for tablets, it is an issue. Here, is the code:

 document.onmouseout = function(e){
    if( e.clientY < 0 ) {
        jQuery("#restoreElement").show();
        jQuery("#restoreElement").delay(5000).fadeOut();
    }
}

I am not aware of events for tablets and how to detect this scenario. Just thinking that touch slide element similar to mouse move/out should help but not sure. Please let me know, if anyone has idea about it.

1

There are 1 answers

0
Thibault Bach On BEST ANSWER

You can't use "onmouseout" or other mouse event with tablet. This is a specific device event like keyboard event.

To use tablet event, see this support list: http://quirksmode.org/mobile/tableTouch.html

You need to create mouse event AND touch event.