react-slick
react-slick copied to clipboard
Sliding broken when slide content is wrapped in anchor tag
When slide content is wrapped inside <a />
tag, sliding behaves weirdly; unusable on FF and Safari, Chrome deals with it somehow.
I believe this comes from here:
img
elements anda
elements with anhref
attribute have theirdraggable
attribute set to true by default.
Here's the code I think is related to this, with the proposed solution:
export const swipeStart = (e, swipe, draggable) => {
e.target.tagName === "IMG" && e.preventDefault();
+ // my proposed solution
+ e.target.tagName === "A" && e.preventDefault();
if (!swipe || (!draggable && e.type.indexOf("mouse") !== -1)) return "";
return {
dragging: true,
touchObject: {
startX: e.touches ? e.touches[0].pageX : e.clientX,
startY: e.touches ? e.touches[0].pageY : e.clientY,
curX: e.touches ? e.touches[0].pageX : e.clientX,
curY: e.touches ? e.touches[0].pageY : e.clientY
}
};
};
What do you think?