window
您可以通过检查其宽度来确定其左侧:
if(e.pageX >= ($(window).width() - 20))
将检查鼠标是否在窗口右侧的 20px 内。
要检查它移动了多远,您需要以某种方式记录最后一个已知位置,然后进行比较。因此,例如,您可能会执行以下操作:
var last_pos = { x: false, y: false },
coord_check = $(window).width() - 20; // or whatever value from the right you want to check.
$(window).on('mousemove' function(e) {
if(e.pageX >= coord_check)
{
// If they're null, we can't do anything:
if((last_pos.x !== false && last_pos.y !== false) && ((e.pageX - last_pos.x) > 20)) {
// you can access the current position through e.pageX and e.pageY
// last_post.x and last_pos.y will tell you the last known position
}
}
// Now we need to update the last position:
last_pos.x = e.pageX;
last_pos.y = e.pageY;
});