feat: expose disableIntervalMomentum as opt-in Picker prop#75
Conversation
|
@yinminqian thanks for the PR and for the detailed investigation in #74. I agree that this is a real issue on the affected Android devices, but I don't think we should enable Since the issue seems to affect a relatively small set of older/OEM Android devices, I think the better direction is to expose this as an explicit <Picker disableIntervalMomentum={true} />Then consumers who hit this device-specific RN/OEM bug can opt into the workaround without changing the default behavior for everyone else. Could you please update the PR to add |
Adds an optional `disableIntervalMomentum` prop to `<Picker />`, threaded through to both the regular `List` (Animated.ScrollView) and the virtualized list (Animated.FlatList). Both already use `snapToOffsets`, so the prop applies on either path. Defaults to React Native's default (off), so existing UX is unchanged. Affected Android devices (vivo / Oppo, see quidone#74 and react/react-native#29922) can opt in via `disableIntervalMomentum={true}` to avoid erratic snap behavior, without changing the default for everyone else.
f59d09e to
f0bf686
Compare
disableIntervalMomentum on list ScrollView to avoid erratic snap on some Android devicesdisableIntervalMomentum as opt-in Picker prop
|
Thanks @rozhkovs — that's a fair point on UX compatibility. Just pushed an update (force-push to keep it a single commit; see
PR title/description updated to match the new approach. Let me know if you'd like the prop named differently (e.g. mirroring RN's name exactly is |
|
@yinminqian Thank you for your work! Added in release 1.7.0. |
Relates to #74.
What
Adds an optional
disableIntervalMomentum?: booleanprop to<Picker />(inPickerProps), threaded through to:src/base/list/List.tsx— the regularAnimated.ScrollViewpath.src/hoc/virtualized/VirtualizedList.tsx— the virtualizedAnimated.FlatListpath. (Both already usesnapToOffsets, so the prop applies on either path, as @rozhkovs requested.)Default is
undefined, which falls back to React Native's default (off). Existing UX is unchanged for everyone.Why
On some older Android devices (reproduced on vivo V2002A / Android 10, and previously reported upstream on vivo / Oppo phones — see facebook/react-native#29922) the wheel exhibits erratic jumping snap behavior: it doesn't settle on the released item, jumping back and forth across multiple items before stopping, sometimes landing on a value the user never visually crossed.
Setting
disableIntervalMomentum={true}eliminates the bug on those devices. Exposing it as an opt-in prop lets affected consumers apply the workaround without changing the picker's interaction semantics for the rest of the user base — which is the right tradeoff, since fast flicks still need to carry through multiple items on healthy devices.Files
src/base/picker/Picker.tsx— adddisableIntervalMomentum?: booleantoPickerProps. (Flows through...restPropsto the renderList.)src/base/list/List.tsx— add the prop toListProps, destructure, pass to the scroll view.src/hoc/virtualized/VirtualizedList.tsx— same, for the FlatList path.README.md— document the new prop under WheelPicker Props.Test plan
yarn tsc:check— clean.yarn test:run— 15 tests passing.