n4kz / react-native-pages

Easy to use page view component
Other
376 stars 83 forks source link

how to disable swipe ? #53

Open krunaldodiya opened 3 years ago

krunaldodiya commented 3 years ago

Hi, this is a nice library, however it would be great if it includes swipeEnabled={false} so that, instead of manually swipe one can use programmatically swiping

guytepper commented 3 years ago

I've achieved this behavior with scrollEnabled prop (undocumented) set to false and the scrollToPage method:

function Onboarding() {
  const pages = useRef(null);

  useEffect(() => {
    pages.current.scrollToPage(2);
  }, []);

  return (
    <View>
      <Pages ref={pages} scrollEnabled={false}>
        <View />
        <View />
        <View />
      </Pages>
    </View>
  );
}