draggable={ false } prevent slide content iteraction
Hello!
When I use carousel with not-image elements and set draggable={ false } , all attempts to interact with content are fails.
Example:
onClickButton = (e) => {
console.log(e);
}
...
<Carousel>
<div>
<p>Slide 1</p>
<button onClick={ this.onClickButton } value='Click me!' /> // Not clickable
</div>
</Carousel>
Hi,
I've run into this issue too and it looks like it's because this.clickSafe has a default of 'true' which prevents default on the event (in handleClick). When draggable is set to true, it dynamically sets clickSafe depending on whether the user is swiping so it behaves correctly (prevents default only when the user is in the middle of a drag/swipe):
handleClick: function handleClick(e) {
if (this.clickSafe === true) {
e.preventDefault();
e.stopPropagation();
if (e.nativeEvent) {
e.nativeEvent.stopPropagation();
}
}
},
handleSwipe: function handleSwipe(e) {
if (typeof this.touchObject.length !== 'undefined' && this.touchObject.length > 44) {
this.clickSafe = true;
} else {
this.clickSafe = false;
}
I think the solution is to default clickSafe to be false when it's defined. In the meantime a quick fix is to call e.stopPropagation() on all your click events so it doesn't bubble up to the carousel.
I believe the real issue is that clickSafe is used to protect against drags / swipes, but when returning the list of drag / touch functions, it doesn't account for the fact that no clicks will be possible without the handleSwipe function having been called. The tricky thing is that clickSafe needs to be true for either swiping or dragging (or both), but not when both are false.
I think a potential solution is to update the default to false, and then modify these two bits of code to switch it to true if either dragging / swiping is allowed:
if (self.props.swiping === false) {
return null;
} else {
this.clickSafe = true;
}
...
if (self.props.dragging === false) {
return null;
} else {
this.clickSafe = true;
}
Guys, any update on the fix for this issue?
This is still an active issue and was addressed with PR #190, PR #220, and PR #266 but they are no longer merge-able into our current repo (so they are closed but the logic they used to solve the problem might still be applicable).
This issue also relates to issue #381.
Even anchors tags are not working because of this. any work around for that?
Here's a PR: https://github.com/FormidableLabs/nuka-carousel/pull/423
fixed in #423