I am struggling with the jQuery mouseleave event on IE11 if I tap a link by touch screen. Every time I tap a link by touch, a mouseleave
event fires afterwards, although I don't tap somewhere else. On Chrome and FF, it works fine as they reposition the actual cursor position whereas IE leaves it at the previous position.
See the following script - works on touchscreens in FF and Chrome, and by using the mouse. http://jsfiddle.net/daSL2/
Expected behaviour: The mouseleave
event should only fire if I move away with the mouse or tap somewhere else by touch screen. (Tested on Lenovo Yoga 13)
JS:
$(function () {
$('a').on({
click: function (e) {
writeDebugText('click');
},
mousedown: function (e) {
writeDebugText('mousedown');
},
mouseenter: function (e) {
writeDebugText('mouseenter');
},
mouseleave: function (e) {
writeDebugText('mouseleave');
}
});
});
var last = new Date();
function writeDebugText(text) {
var o = $('div.Debug');
var now = new Date();
var diff = now.getTime() - last.getTime();
o.html(text + " @ " + diff + " <br /> " + o.html());
last = now;
}
HTML:
<a href="#" style="-ms-touch-action: none; touch-action: none;">Click me</a>
<hr />
<em>
<div class="Debug"></div>
</em>
Thanks for your help!