Z
Z
zzxxxxzz2019-01-10 11:15:00
HTML
zzxxxxzz, 2019-01-10 11:15:00

Why are links clicked on scroll in a responsive template?

Hello. There was an adaptive template on DLE. Moved it to wordpress. wp encountered a problem when working with mobile devices. When you scroll any page, you immediately click on the link that was under your finger at the time of the scroll. I don’t know how to describe it more precisely ... it’s better to look. Site: lechenie-kemerovo.ru
Maybe wp has some peculiarities in this regard? (never worked with it)
Or did I do something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rustam Bainazarov, 2019-01-10
@zzxxxxzz

function toggleSubmenuDisplay() {
    document.addEventListener('touchstart', function(event) {
        // ВОТ ЭТОТ КУСОК -- НАЧАЛО
        if (event.target.matches('a')) {
            var url = event.target.getAttribute('href') ? event.target.getAttribute('href') : '';
            if ('#' !== url && '' !== url) {
                window.location = url;
            } else if ('#' === url && event.target.nextSibling.matches('.submenu-expand')) {
                openSubMenu(event.target);
            } else {
                event.preventDefault();
            }
        }
        // ВОТ ЭТОТ КУСОК -- КОНЕЦ

    ...

It's all because of him. You need to rewrite or remove it nafig. It handles all links. Given the fact that I don't see elements with the submenu-expand class in the markup, I would comment out this section in its entirety and see what's broken. If nothing broke, I would have left it that way.

A
Anatoly Kulikov, 2019-01-10
@anatoly_kulikov

Now Captain is writing on my behalf, but what is available: when scrolling on a mobile phone, touching the screen and launches the function, which is why the link works. There is actually only one way out - to remove the script.
WP has no features, it just pulls data from the database. How they are displayed and what happens to them is a question for the topic (and the developer).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question