woutervh-/react-pan-and-zoom-hoc

onMouseLeave doesn't trigger onPanEnd

robrechtme opened this issue · 4 comments

When panning and your mouse leaves the bounds of the component, you expect the panning to stop.
When you release the mouse and re-enter the component, it is still panning, even though the user isn't holding the mouse down.
A more expected behaviour is that the panning simply stops when you leave the component.

Hi @RobrechtM ,

Let me understand more clearly, do you want:

  • the panning to stop as soon as the mouse leaves the box, even if the user is still holding down the mouse button, or
  • the panning to stop when the user lets go of the mouse button, regardless of whether the mouse is still inside the component?

Thanks

Thanks for your quick response, and interesting remark.
I think it makes more sense to implement the second one. When the user enters the box with the mouse still down, the panning should continue.

Hi @RobrechtM ,

I've published version 1.2.0, and to remain backwards compatible have kept the old behavior and added a new flag:

ignorePanOutside

Using the new flag you can choose to ignore panning when the mouse exits the element.
I also changed the panning values to represent the center of the element, instead of the offset. X and Y are inverted (* -1). Zooming with the wheel should also be fixed by this.

Please let me know if this is working as intended for you.

Closing for housekeeping purposes.