Comments (11)
This can already be done using the scrollTo(index) method.
from react-native-swiper.
Can you clarify how one might use this? Does this require two-way binding? I.e. swiping modifies an index state variable, and modifying a state variable switches to a given slide? That would require extending this component with that behavior, right?
from react-native-swiper.
The way I am doing it in my project is assigning ref to it , you can do something like :
<Swiper style={styles.wrapper} ref={component => this._swiperobj = component} > ... </Swiper>
Then you can call this._swiperobj.scrollTo(1);
or something like that based on your condition .
from react-native-swiper.
Oh wow, I didn't know that was a thing you could do. I was doing it with two-way binding, e.g.:
<Swiper
index={this.state.swiperIndex}
onIndexChange={(idx) => this.setState({swiperIndex: idx})}
>
which of course requires implementing onIndexChange
within Swiper, but I'm already digging through guts to solve a couple other corner cases…
from react-native-swiper.
And also requires picking up index
prop changes within Swiper. The ref method seems kind of like a hack, but it's pretty compelling when you just need to get the job done.
from react-native-swiper.
Yes , ref is a powerful tool , and by the way , why do you feel it looks like a hack ? It doesn't cost on performance or usability .
from react-native-swiper.
At any rate, I think I'll finish implementing the two-way method since it's more react-ish and should probably exist anyway. Commits will probably end up on this fork (if I can get the infinite loop case working): https://github.com/manandmoon/react-native-swiper
from react-native-swiper.
@nautical revisiting this with some hindsight (and because it's now painfully unmaintained and doesn't work anymore). Yeah, you're totally right. That's way easier and perfectly reactish. Noob mistake. But looks like now we'll have to swap this out for react-native-viewpager.
from react-native-swiper.
@leecade is alive!!!
from react-native-swiper.
@olivierlesnicki yeah I work on RN again
from react-native-swiper.
@nautical MY HERO <3
from react-native-swiper.
Related Issues (20)
- Data is not displayed correctly when the data is changed
- Is this still maintained? Or EOL? HOT 5
- how to prevent user to not come on first screen after the last swipe?
- how to detect swipe left or right HOT 1
- ViewPropTypes will be removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types HOT 4
- how to swipe to next screen when user press the button HOT 1
- 好像停更了?
- flicker in the area of <Swiper> Component when swiping on the latest version of react-native HOT 4
- Position: aboslute won't make button clickable
- In the case of iPhone, touch is not available when using Flatlist items.
- Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types' HOT 1
- OnIndexChanged
- Just don't use this lib. HOT 3
- [All-iPhone-Device] Two photos are displayed in one picture in the Swiper HOT 1
- Add animation to update pagination dot while swiping HOT 2
- Warning: Failed prop type: The prop `children` is marked as required in `_default`, but its value is `undefined`. HOT 1
- index value will be out of reange after updating the UseState
- How can we make screen transitions by touching dots? How can I add a background to the dots?
- How to adjust spacing of pagination dots ?
- onIndexChanged getting wrong value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-swiper.