Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

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

Open
zxyah opened this issue Dec 28, 2015 · 11 comments
Open

Comments

@zxyah
Copy link

zxyah commented Dec 28, 2015

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

@DaveAdams88
Copy link

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

@iicdii
Copy link

iicdii commented Jan 11, 2016

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

@hufeng
Copy link

hufeng commented Jan 21, 2016

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

@chirag04
Copy link

chirag04 commented Feb 2, 2016

+1. using _close for now.

@braco
Copy link

braco commented May 11, 2016

Check out the example

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

@Yuzeyang
Copy link

Yuzeyang commented Oct 9, 2016

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

@xuanpyco
Copy link

xuanpyco commented Jan 3, 2018

+1. I'm using _close too.

@olejka91
Copy link

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

@xuanpyco
Copy link

@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}
 />
}
}

@olejka91
Copy link

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

zuoyoulian pushed a commit to zuoyoulian/react-native-swipeout that referenced this issue May 7, 2018
fix warnings about keys for dots
@kalraneeraj24550
Copy link

thanks @xuanpyco sir, your solution worked for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants