Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While Sliding item a tag is clicked #81

Open
AH72KING opened this issue Sep 7, 2018 · 4 comments
Open

While Sliding item a tag is clicked #81

AH72KING opened this issue Sep 7, 2018 · 4 comments

Comments

@AH72KING
Copy link

AH72KING commented Sep 7, 2018

I have structure in which li has an image which is surronded by an a tag, upon slide item is clicked how can i prevent that

<div class="carousel" id="scrolling">
<ul>
    <li>
      <div class="product-thumbnail">
          <a href="deal-x5"><img src="270.png"></a>
      </div>
    </li>
<ul>
</div>
@nir9
Copy link
Owner

nir9 commented Apr 5, 2019

If I understand correctly you mean what happens when you mousedown and drag on a link inside a slide, you can disable this behavior by calling preventDefault on the mousedown event on the link element, see the following example : https://jsfiddle.net/rg0cq8Lf/3/

Maybe I'll add an option to the library that will does this for all links in the carousel..

@fwebdev
Copy link

fwebdev commented Apr 24, 2019

Unfortunatly the solution is not working. The Link is been called when you start sliding on the Link. You don't see any effect, because the Link goes to '#'. So you stay on the same Page.

I forked the jsFiddle and added real links to the href: https://jsfiddle.net/7uj1cer9/

@PurHur
Copy link

PurHur commented Apr 24, 2019

This is a browser wide topic. What do you use to test? Welcome in the world of browsers and their implementation 🎉

I made quick tests that works for me in chrome. Feel free to test it in all browsers and versions.

$("a").on("mousedown touch click", function(event) {
  event.preventDefault();
});

@PurHur
Copy link

PurHur commented Apr 24, 2019

Quick idea:
I think a other "hotfix" will work better for you:
create an onDragStart function wich sets https://developer.mozilla.org/de/docs/Web/CSS/pointer-events on all links to none.
After onDragEnd you remove that css command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants