react-native-swipeout icon indicating copy to clipboard operation
react-native-swipeout copied to clipboard

how can i close all opened swipe、only can open one swipe at the same time?

Open zxyah opened this issue 9 years ago • 11 comments
trafficstars

i wish can close an opened swipe,the way ? if i swipe a row's button, when i swipe at another row, i hope close other swipe, how ? @dancormier

zxyah avatar Dec 28 '15 08:12 zxyah

+1 I'm looking to close the open swipeout item when scrolling the Scrollview

DaveAdams88 avatar Jan 10 '16 15:01 DaveAdams88

I think it will work with onOpen, _close method in Swipeout and componentWillReceiveProps lifecycle in ListView item component.

iicdii avatar Jan 11 '16 09:01 iicdii

+1, now i am directly use a ref to call _close

hufeng avatar Jan 21 '16 13:01 hufeng

+1. using _close for now.

chirag04 avatar Feb 02 '16 21:02 chirag04

Check out the example

https://github.com/dancormier/react-native-swipeout/blob/master/example/index.ios.js

braco avatar May 11 '16 17:05 braco

@hufeng i am directly call _close too, but it can not work, can you show your code?

Yuzeyang avatar Oct 09 '16 02:10 Yuzeyang

+1. I'm using _close too.

xuanpyco avatar Jan 03 '18 08:01 xuanpyco

@xuanpyco Hi, can you provide me with your solution? Becuase I use ref, call _close and it does not work. Thanks in advance

olejka91 avatar Mar 24 '18 21:03 olejka91

@olejka91 I ended up a solution as following.

class ListItem extends Component {

_onSwipeOpen = () => {
this.props.onSwipeOpen(this.swipeInstance);
}

render() {
return (
<SwipeOut
ref={instance => this.swipeInstance = instance}
onOpen={this._onSwipeOpen}
/>
);
}

}

class MyList extends Component {

_onSwipeOpen = (swipeInstance) => {
if(this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) {
this.currentlyOpenSwipe._close();
}

this.currentlyOpenSwipe = swipeInstance;
}

_renderRow  = () => {
 return (
<ListItem
 onSwipeOpen={this._onSwipeOpen}
/>
);
}

render(){
return (
<ListView
renderRow={this._renderRow}
 />
}
}

xuanpyco avatar Mar 27 '18 02:03 xuanpyco

@xuanpyco I just replaced this library with a react-native-swipe-list-view. Thanks for reply

olejka91 avatar Mar 27 '18 05:03 olejka91

thanks @xuanpyco sir, your solution worked for me.

kalraneeraj24550 avatar Sep 25 '19 11:09 kalraneeraj24550