akveo / akveo/react-native-ui-kitten
ViewPager onSelect shouldn't fire on animation scroll
- Lenguaje dominante
- TypeScript
- Estrellas
- 10.7k
- Forks
- 962
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
## 🐛 Bug Report
When changing the state of the selected index in ViewPager to skip some pages (for example jump from 0->10), `onSelect` gets fired for the pages in-between while scrolling animation is running (gets fired as if the user selected page 1, then 2 ... until 10).
## To Reproduce
Steps to reproduce the behavior:
A simple ViewPager bound with a `selectedIndex` state, then change the state from the initial (0) to 10.
## Expected behavior
The animation shouldn't fire `onSelect` during the animation scroll.
## Link to runnable example or repository (highly encouraged)
https://snack.expo.io/aQLsN7uXx
Run it and check for the logs to verify that `onSelect` gets fired for some pages in-between.
## Workaround & Suggested solution
Seems that binding a ref and using `scrollToIndex` instead of changing the state directly doesn't reproduce the bug.
Maybe we should:
1. Update the docs to at least give a hint on this behavior + mention that is it possible to use `scrollToIndex` (currently there are no functions docs on ViewPager)
2. Seperate between `onPageSelect` and `onPageVisible` (or `onPageScroll` which is currently called `onSelect`)
## UI Kitten and Eva version
| Package | Version |
| ----------- | ----------- |
| @eva-design/material | 2 |
| @ui-kitten/components | 5 |
## Environment information
```bash
System:
OS: macOS 10.15.6
CPU: (6) x64 AMD Ryzen 5 3500X 6-Core Processor
Binaries:
Node: 14.7.0 - /usr/local/bin/node
npm: 6.14.11 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0
System Images: android-28 | Google Play Intel x86 Atom_64
Android NDK: 21.3.6528147
IDEs:
Xcode: 12.3/12C33 - /usr/bin/xcodebuild
npmPackages:
react: ^16.14.0 => 16.14.0
react-native: 0.63.3 => 0.63.3
npmGlobalPackages:
react-native-cli: 2.0.1
```
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.