SpyrexDE / SmoothScroll

Addon for the Godot Game Engine that adds a SmoothScrollContainer.
https://spyrexde.github.io/SmoothScroll/
MIT License
132 stars 10 forks source link

Support trackpad scroll with InputEventPanGesture #40

Open jmoon1506 opened 6 months ago

jmoon1506 commented 6 months ago

Enable two finger scrolling on MacBooks with InputEventPanGesture events.

SpyrexDE commented 6 months ago

I just added basic support, however, this will need more work for it to feel not as spongy as it is right now: https://github.com/SpyrexDE/SmoothScroll/blob/2759650b020d273b3afbb90dd9e014f986e23adc/addons/SmoothScroll/SmoothScrollContainer.gd#L240-L244 The current implementation ignores overdrag and relies on the scroll wheel speed variable which is not optimal.

HaroldLever commented 6 months ago

Probably considering pan gesture as dragging would be a better way? But I don't know there is any way to know when gesture starts or ends. Another way is to calculate velocity that is needed to scroll to specific destination.

SpyrexDE commented 6 months ago

Probably considering pan gesture as dragging would be a better way? But I don't know there is any way to know when gesture starts or ends.

I thought about that as well, however, it is exactly as you say. Reading the pan gesture is quite different to reading dragging. The pan gesture only provides a delta (how much the value changed) whereas when reading dragging we know when it starts and when it ends.