Added ability to request reach out ratio of swipe.

This commit is contained in:
23rd 2025-03-16 18:57:46 +03:00
parent f3ea24f9f9
commit ad9106b815
2 changed files with 10 additions and 0 deletions

View file

@ -213,6 +213,7 @@ void SetupSwipeHandler(
if (!state->started || state->touch != args.touch) { if (!state->started || state->touch != args.touch) {
LOG(("STARTING")); LOG(("STARTING"));
state->started = true; state->started = true;
state->data.reachRatio = 0.;
state->touch = args.touch; state->touch = args.touch;
state->startAt = args.position; state->startAt = args.position;
state->cursorTop = widget->mapFromGlobal(args.globalCursor).y(); state->cursorTop = widget->mapFromGlobal(args.globalCursor).y();
@ -265,6 +266,14 @@ void SetupSwipeHandler(
base::Platform::Haptic(); base::Platform::Haptic();
} else if (state->reached } else if (state->reached
&& ratio < kResetReachedOn) { && ratio < kResetReachedOn) {
if (state->finishByTopData.provideReachOutRatio) {
state->animationReach.stop();
state->animationReach.start(
animationReachCallback,
1.,
0.,
kBounceDuration);
}
state->reached = false; state->reached = false;
} }
} }

View file

@ -23,6 +23,7 @@ struct SwipeHandlerFinishData {
int64 msgBareId = 0; int64 msgBareId = 0;
float64 speedRatio = 1.0; float64 speedRatio = 1.0;
bool keepRatioWithinRange = false; bool keepRatioWithinRange = false;
bool provideReachOutRatio = false;
}; };
using Scroll = std::variant< using Scroll = std::variant<