react-swipeable-list icon indicating copy to clipboard operation
react-swipeable-list copied to clipboard

Button component in content prop

Open ziabskiK opened this issue 4 years ago • 8 comments

How is it possible to trigger onClick function on button which is located as a content of swipe element?

Any tip how to achieve this?

Thanks in advance. Edit Code: {({ className, ...rest }) => (

<SwipeableListItem key={id} swipeLeft={{ content: <Button startIcon={<AddShoppingCartIcon/>} className={classes.addToCartBtn} onClick={e => { e.stopPropagation(); console.log('Test function call'); }}> Add to cart </Button>, actionAnimation: ActionAnimations.NONE }} {...rest}> ///items </SwipeableListItem>

))}

ziabskiK avatar Jul 07 '20 09:07 ziabskiK

I assume you want to achieve the iphone functionality like showing few buttons after swipe?

It looks like you can so far do the thing you've mentioned above with the swipeRight prop. It currently does not work for the 'left' content as it is rendered 'under' the right content. So a little fix would need to be done to not only change the opacity of the swipe content items but also the display style.

Let me know if this is needed and try if you can achieve the behavior you need with the swipeRight prop.

marekrozmus avatar Jul 11 '20 21:07 marekrozmus

@all-contributors please add @ziabskiK for bug

marekrozmus avatar Sep 07 '20 08:09 marekrozmus

@marekrozmus

I've put up a pull request to add @ziabskiK! :tada:

allcontributors[bot] avatar Sep 07 '20 08:09 allcontributors[bot]

We have checked this issue and current architecture does not allow this. We will monitor this issue and get back to you if more users will be interested in such a feature. Most probably, a huge rewrite is needed to support your request as the inner node layout and positioning is pretty complicated.

marekrozmus avatar Sep 09 '20 14:09 marekrozmus

well i searched everywhere for that functionality that you mention , when you swipe it reveals the content behind and stays like that for you to click on a button, like here , i don't want to use react-native-web just for that

Ex0-Ghost avatar Dec 01 '20 17:12 Ex0-Ghost

Hi, I'll try to make another try hopefully this weekend. Will let you know. 🙂

marekrozmus avatar Dec 03 '20 14:12 marekrozmus

I would also love to see this feature. We're trying to mimic the behavior of a native swipeable iOS listview as much as possible, but this would require buttons that are revealed if you just swipe a bit (but not beyond a certain threshold). react-swipe-to-delete-ios supports this, but it has other issues (like rubber-banding of the enclosing web-page).

derwaldgeist avatar Jan 04 '21 14:01 derwaldgeist

@derwaldgeist, @Ex0-Ghost Please check this one and leave some comments there :) I have reimplemented all from scratch so still might have some issues. https://github.com/marekrozmus/react-swipeable-list

marekrozmus avatar Feb 06 '21 14:02 marekrozmus