Scrolling is also "non-smooth" in FF, etc. if you scroll fast enough.
I just have a feeling this isn't going to be worth it, but what you might need to do is:
- onload, get the position of each anchor and determine its area
- collect all possible coordinates into an array of objects (an index)
{ id: 'my-anchor-1', x: 100, y: 100 }
- onmousemove, check your coordinates against your array (i.e., check each coordinate between the old mouse position and the new mouse position, as other commenters have said).
This way you do most of the calculations and DOM selection up front and make it much easier for the mousemove event. This could get messy if content added to the page later shifts the anchors around: you'd have to recalculate the array, but that happens less frequently relative to mousemove, and if all you ever do is append, you could simply add to it.
Addressing the resize issue, et al. It really depends on who your audience is and how many anchors you think you're going to have as a worst case scenario. Because this is mousemove, we're talking about desktops/laptops where resizing the window would be very infrequent, especially relative to mousemove events.
If you only have a handful of anchors, and you think there will be a lot of shifting, then creating an index doesn't make as much sense, and you can do the calculation in the event itself (but at least cache the DOM selection). But if you think you'll have a ton of anchors, especially if they aren't likely to shift a lot, I think indexing them makes a lot of sense for performance reasons.