A
A
Ambal892017-08-28 17:37:12
HTML
Ambal89, 2017-08-28 17:37:12

How to disable mouse scroll on Yandex map?

Good afternoon, I made a Yandex map a map constructor, brought it to the site through an iframe, set scroll=false , but the map still spins with a wheel. I've never experienced this before, which is why I'm posting here.
Card code just in case.

<iframe src="https://yandex.ru/map-widget/v1/?um=constructor%3Ac94e45d7f53bf7d35e1ae3e4946b0966305666753488de23effbc47e7d2d337f&amp;lang=ru_RU&amp;scroll=false&amp;source=constructor" width="100%" height="450" frameborder="0"></iframe>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Feninets, 2017-08-28
@Ambal89

you can just switch pointer-events.
Something like this, for example:
demo

<div style="height: 2000px; width: 400px; margin: 0 auto;" id="map-wrap">
            <iframe style="pointer-events: none;" src="https://yandex.ru/map-widget/v1/?um=constructor%3Ac94e45d7f53bf7d35e1ae3e4946b0966305666753488de23effbc47e7d2d337f&amp;lang=ru_RU&amp;scroll=false&amp;source=constructor" width="100%" height="100%" frameborder="0"></iframe>
        </div>

document.addEventListener('click', function(e) {
                var map = document.querySelector('#map-wrap iframe')
                if(e.target.id === 'map-wrap') {
                    map.style.pointerEvents = 'all'
                } else {
                    map.style.pointerEvents = 'none'
                }
            })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question