DanFessler / react-panelgroup

A react component for resizable panel group layouts:
https://danfessler.github.io/react-panelgroup/
MIT License
254 stars 53 forks source link

Optional "Handle" for Panels #22

Open pdfowler opened 6 years ago

pdfowler commented 6 years ago

I've seen a handful of implementations of panels like this where there's a small "handle" on the resizer divider. This can be really useful for mobile (eg: #16 )since it is often more useful to "toggle" panels on mobile rather than drag to resize.

This is something I'm looking at doing, but wanted to file an issue first to see if anyone in the community had implemented something like this.

Proposed Behavior:

  1. Add an optional parameter "handle" to the panelWidths configs object
  2. Default behavior would toggle between the "minSize" and the "maxSize" (see #20 & my associated PR)
  3. Additional callback onHandleClick called with arguments panels (like current onUpdate method), along with the panelIndex of the selected panel divider.
  4. Dragging a panel handle would act the same as dragging the panel divider (eg: onHandleClick would only fire onMouseUp if isDragging === false

Questions:

What does panelIndex refer to?

If a handle is placed on panel 0, it is placed on the divider between panels 0 and 1. This is straightforward. In a three column layout with a stretch column between two sidebars, does the handle for the righthand sidebar go on panel 1 or panel 2?

possible solution: handle could take either a single DOM element (as described above, ie: "basic config mode"), or it could take an object with properties: handle.component, handle.direction, etc

DanFessler commented 6 years ago

I like this proposal. I have some followup comments/questions

vladp commented 6 years ago

May be name could be 'dividerHandle' as the handle applies to dividers. Example that I found with 'a handle' (may be not the prettiest one) is https://codepen.io/rstrahl/pen/eJZQej

Also, since this would be great for Mobile, ability to recognize gestures is important (but please do not use Hammer.js for those, as Hammer.JS does not support server-side deployment, which is a problem, at least for me :-) )

lrengunst commented 5 years ago

I want to remove the cursor in the content tag