akshathjain / sliding_up_panel

A draggable Flutter widget that makes implementing a SlidingUpPanel much easier!
https://pub.dartlang.org/packages/sliding_up_panel
Other
1.38k stars 381 forks source link

Click on panel closes the panel when opening with controller.open() #102

Closed sgehrman closed 4 years ago

sgehrman commented 4 years ago

I have it set to minHeight: 0. I want it hidden until I click a floatingActionButton and it calls controller.open(). The first time it works. I click the button and the panel is open and clicking the panel is OK, but if I drag to close the panel, and then open it again, any clicks on the panel will close the panel. Unless I drag the panel down a bit and back up, then clicks work without closing. Some variable must be getting out of sync.

sgehrman commented 4 years ago

figured out the bug. Add this to Listener...

The problem was caused by the velocity tracker thinking the last velocity was my swipe down to close the panel. Then when I used the controller.open() and my first tap would trigger the onPointerUp and would think I swiped down because of the velocity set. Adding the onPointerDown will tell the velocity tracker I just clicked and the onPointerUp after that won't animated it away.

 return Listener(
      onPointerDown: (PointerDownEvent p) {
        _vt.addPosition(p.timeStamp,
            p.position); // add current position for velocity tracking
      },
sgehrman commented 4 years ago

?

akshathjain commented 4 years ago

Will try to reproduce and implement the proposed fix in the v1.0.1

akshathjain commented 4 years ago

This has been fixed and will be pushed in the next release (v1.0.1).