Bug 1782631. Don't draw swipe to nav arrows at 100% of animation if navigation won't occur. r=hiro

We need to pass the event amount to StartAnimating otherwise we start animating from 100% as we fade the UI arrow away.

Differential Revision: https://phabricator.services.mozilla.com/D153455
This commit is contained in:
Timothy Nikkel 2022-08-03 10:50:41 +00:00
parent aeb018ca75
commit 8d1c0ac936
2 changed files with 17 additions and 4 deletions

View File

@ -152,6 +152,19 @@ nsEventStatus SwipeTracker::ProcessEvent(
eventAmount = -eventAmount;
}
}
// If ComputeSwipeSuccess returned false because the users fingers were moving
// slightly away from the target direction then we do not want to display
// the UI as if we were at the success threshold as that would give a false
// indication that navigation would happen.
if (!computedSwipeSuccess && (eventAmount >= kSwipeSuccessThreshold ||
eventAmount <= -kSwipeSuccessThreshold)) {
eventAmount = 0.999 * kSwipeSuccessThreshold;
if (mGestureAmount < 0.f) {
eventAmount = -eventAmount;
}
}
SendSwipeEvent(eSwipeGestureUpdate, 0, eventAmount, aEvent.mTimeStamp);
if (aEvent.mType == PanGestureInput::PANGESTURE_END) {
@ -168,15 +181,15 @@ nsEventStatus SwipeTracker::ProcessEvent(
swipeTracker->SwipeFinished(timeStamp);
}));
} else {
StartAnimating(0.0);
StartAnimating(eventAmount, 0.0);
}
}
return nsEventStatus_eConsumeNoDefault;
}
void SwipeTracker::StartAnimating(double aTargetValue) {
mAxis.SetPosition(mGestureAmount);
void SwipeTracker::StartAnimating(double aStartValue, double aTargetValue) {
mAxis.SetPosition(aStartValue);
mAxis.SetDestination(aTargetValue);
mAxis.SetVelocity(mCurrentVelocity);

View File

@ -76,7 +76,7 @@ class SwipeTracker final : public nsARefreshObserver {
double SwipeSuccessTargetValue() const;
double ClampToAllowedRange(double aGestureAmount) const;
bool ComputeSwipeSuccess() const;
void StartAnimating(double aTargetValue);
void StartAnimating(double aStartValue, double aTargetValue);
void SwipeFinished(const TimeStamp& aTimeStamp);
void UnregisterFromRefreshDriver();
bool SendSwipeEvent(EventMessage aMsg, uint32_t aDirection, double aDelta,