Trancever / reanimated-collapsible-helpers

reanimated-collapsible-helpers-git-master.trancever.vercel.app
MIT License
157 stars 26 forks source link

Programatically open the draw or make it default as opened #29

Open LHowlett97 opened 2 years ago

LHowlett97 commented 2 years ago

Hi, sorry if this is an obvious question but is there a way to programatically open the drawer without the user tapping on it? Eg. another button on the page.

Additionally, is there a way to change the default behaviour to be opened.

Thanks.

Trancever commented 2 years ago

@LHowlett97 Hi mate 👋

Sorry for long response, but I no longer work on React-Native projects and I don't have much time for RN related open source these days.

You can programatically expand/collapse by calling onPress handler returned from useCollapsible hook. You can pass it to any button or call this function in any other function/handler or on component mount for example.

If it comes to default "expanded" state then it's not currently supported (Feel free to submit a PR with this feature, it would be awesome). Anyway, as a workaround you could try to call onPress (as mentioned above) on component mount, but this might be a little bit slow and not the best UX.