0

i have a page with an object where you can zoom in and out. now i want to find a way to run a special zoom function if the user scrolls and the cursor is over this object at this time.

if the cursor is somewhere else the page should scroll normal but the page should not move if the cursor is over this object.

the problem what i am having now is, there could be an extra function which can detect if the cursor is over the image and save it, but this does not prevent the page from scrolling

Friedrich
  • 1,592
  • 15
  • 33

1 Answers1

1

You can use mouseover and mouseout or mouseenter and mouseleave events to detect if the cursor is over the image. You could also use the mousewheel event and stop the propagation and prevent the default behaviour.

document.getElementById("noscroll").addEventListener("mousewheel", function (event) {
  event.preventDefault();
  event.stopPropagation();
}, false);
Poetro
  • 574
  • 3
  • 9
  • @frieder could you give more details then, I don't understand the issue enough in that case. – Poetro Mar 12 '14 at 10:55
  • the page should be scrollable but as long as the curser is not over a certain point. how do i prevent the page from scrolling – Friedrich Mar 12 '14 at 12:51