Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with dragging when <Draggable> in ScrollView or FlatList #142

Open
adrian19hub opened this issue Mar 9, 2023 · 1 comment
Open

Comments

@adrian19hub
Copy link

Hi everyone,
When the draggable is in ScrollView or FlatList they dont show on the screen, as if hidden. even with high zIndex
The issue doesn't appear when using standard view.
this is the code:

const DriversList: React.FC<{ data: IPublicDriver[] }> = ({ data }) => {
    const { t } = useTranslation();

    const [scroll, setScroll] = React.useState(true);
    const scrollRef = React.useRef<ScrollView>(null);

    return (
        <ScrollView
            ref={scrollRef}
            scrollEnabled={scroll} //when scroll false scroll view gesture will be disable and vice versa
            showsHorizontalScrollIndicator={false}
            showsVerticalScrollIndicator={false}
        >
            {data.map((driver, index) => (
                <View>
                    <Draggable
                        onLongPress={() => {
                            setScroll(false); // important step to disable scroll when long press this button
                        }}
                        onRelease={() => {
                            setScroll(true); // important step to enable scroll when release or stop drag
                        }}
                        children={<BaseText>{driver.nickName}</BaseText>}
                    />
                </View>
            ))}
        </ScrollView>
    );
};

Thank you

@rizki-tabist
Copy link

I think you can use this https://www.npmjs.com/package/react-native-draggable-flatlist for Flatlist

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

No branches or pull requests

2 participants