Sliding broken when slide content is wrapped in anchor tag
- 主要言語
- JavaScript
- スター
- 11.9k
- フォーク
- 2.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
[example on CodeSandbox](https://codesandbox.io/s/7y27y70no1)
When slide content is wrapped inside `` tag, sliding behaves weirdly; unusable on FF and Safari, Chrome deals with it somehow.
I believe this comes from here:
> `img` elements and `a` elements with an `href` attribute have their `draggable` attribute set to true by default.
[HTML spec - Drag and drop](https://html.spec.whatwg.org/multipage/dnd.html#drag-and-drop-processing-model)
Here's the code I think is related to this, with the proposed solution:
```diff
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
}
};
};
```
[source](https://github.com/akiran/react-slick/blob/master/src/utils/innerSliderUtils.js#L307)
What do you think?
コントリビューションガイド
評価
この issue はまだ評価されていません。