Webkit firing mousemove event unexpectedly (mouse not moving)

I have a slideshow playing that scrolls a div to reveal the next photo in the slideshow. I also have a function set up that hides the photo description when the mouse is inactive, but shows the description when the mouse moves.

In Firefox, there is no problem, the div scrolls to new photos and no mousemove event is fired. However, in Webkit with the mouse on the window, but inactive, two-three mousemove events are fired every time the div scrolls to a new photo.

Here’s the website for you to have a look. Navigate to the portfolio page in a webkit browser (with a console open I suppose) and that footer should stay hidden while the photos cycle through.

2 thoughts on “Webkit firing mousemove event unexpectedly (mouse not moving)”

  1. Yes, webkit browsers do that, and i think every browser should. Because the cursor IS in a different position after the scrolling, and that could avoid me a lot of problems as a developer.

    Anyway, if you want to avoid its consequences in your script, just log the latest clientX and clientY position and check if those have changed since the last “mousemove”; something like this:

        if(window.lastX !== e.clientX || window.lastY !== e.clientY){
            // Code when the (physical) mouse actually moves
        window.lastX = e.clientX
        window.lastY = e.clientY

Leave a Comment