P
P
Pavel2015-06-19 22:19:26
JavaScript
Pavel, 2015-06-19 22:19:26

How to disable scroll wheel on google map without using API?

I would like to just take an iframe map and turn off the zoom with the scroll wheel. How to do it painlessly? I don’t want to contact the API there is a quiet horror in the code

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Petrov, 2015-06-19
@mrusklon

Everything is simple if you know about the 3 phases of events.
By using Capture Phase and stopPropagation , we simply prevent the event from descending from window to the target node.

document.addEventListener('mousewheel', cancel, true); // webkit + IE
document.addEventListener('DOMMouseScroll', cancel, true); // Самые древние FF
document.addEventListener('MozMousePixelScroll', cancel, true); // FF с версии 3.5
document.addEventListener('wheel', cancel, true); // FF с версии 31

function cancel (e) {
  e.stopPropagation();
}

V
Victor Victor, 2015-06-19
@toptalo

scrollwheel: false

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question