Foster
Foster

Reputation: 11

How to Prevent button click action on mobile touch (scroll for example)

I have a website that uses third party button, that works great on PC. However on mobile when you just touch it (to scroll through it for example), it activates and does the button action.

Is there any idea how could I fix it and prevent "clicking" action while just touching the screen on mobile? Thanks a lot

Other buttons dont have this issue and code looks good, I'm stuck - tried other solutions like touch-callout or touch-action: none in css, but it's not fixing the issue

<div class="buttonspopup-actions">
        <a class="button go-button" href="#">Button</a>
</div>

Upvotes: 1

Views: 1054

Answers (1)

Axel EsZu
Axel EsZu

Reputation: 41

Have you tried adding conditional to events?

    if(screen.width<480){
      button.addEventListener("click", function(e){
      e.preventDefault();
      //do something else
    });
    }

Or maybe use swipe events library like https://api.jquerymobile.com/swipe/

Upvotes: 1

Related Questions