Closed HaroldLever closed 9 months ago
It looks like you removed damping for dragging completely, however, damping when overdragging was wanted behaviour. The problem described in #27 is only occuring when the mouse is moved fast enough.
Edit: Nevermind, you actually have added overdragging, however with the same values it behaves very differently to the previous implementation.
I think your implementation is really good, but the documentation could be better. I still dont fully understand what you did 😅
@SpyrexDE Sorry for forgetting to explain that the damping behavior might be slightly different than before, I changed the factor in the latest commit. Is it the effect you want?
Yeah, the result is great and will infact fix #27.
Im just unsure about what the variable "a" is and how pow(delta + pow(a, 1/(1-a)), a) - pow(pow(a, 1/1-a), a)
works.
Could you maybe try to explain a bit how your solution in general works? I would greatly appreciate that :)
Well, instead of applying velocity, I chose to set position directly, but I set velocity to let it scroll once dragging ends.
y_pos = calculate_position.call()
velocity.y = y_pos - pos.y
pos.y = y_pos
Therefore, velocity should not be added to position when dragging.
if not content_dragging: axis_pos += axis_velocity
I chose mouse/touch relative movement to calculate where the content's position should be. Assuming y is position and x is event's relative movement.
The derivatives when x equals 0 should be 1 to make it a continuous function. Although I think it might be too complex.
The rest part is to modify the factor to make it looks good.
var a = (1 - damping * 0.5 - 0.1)
That helped a lot, thank you so much!
To fix #27 .