In React Native, is there any way to resize a Drawer with a resize handle by dragging the edge of the Drawer. For example, like in the Slack screenshot here. This is a very common use case but see no implementation of it anywhere online.
I think it’s possible with Pan Gestures but don’t see a way to get a divider between the Drawer and Screen View.
2
Answers
Thanks SugarFreeBeef, based on that I made a slight modification so it works by dragging a handle on the edge. Here is a working example
To achieve a resizable drawer with a resize handle in React Native, you can utilize the PanResponder API to handle the pan gestures and update the width of the drawer dynamically. Here’s a general approach to implementing this feature:
In the above code,
INITIAL_DRAWER_WIDTH
represents the initial width of the drawer, and you can customize it to suit your requirements. TheonPanResponderMove
function is responsible for updating the drawer width based on the horizontal movement during the pan gesture.By attaching the pan responder to the resizable drawer view and updating its width dynamically, you can achieve the desired resizable behavior with a resize handle in React Native.