mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 976035: Cap max fling velocity at pref'd limit. r=kats
This commit is contained in:
parent
1c29156009
commit
f6b39805f3
@ -47,12 +47,19 @@ static float gFlingStoppedThreshold = 0.01f;
|
||||
*/
|
||||
static uint32_t gMaxVelocityQueueSize = 5;
|
||||
|
||||
/**
|
||||
* Maximum velocity in pixels per millisecond. Velocity will be capped at this
|
||||
* value if a faster fling occurs. Negative values indicate unlimited velocity.
|
||||
*/
|
||||
static float gMaxVelocity = -1.0f;
|
||||
|
||||
static void ReadAxisPrefs()
|
||||
{
|
||||
Preferences::AddFloatVarCache(&gMaxEventAcceleration, "apz.max_event_acceleration", gMaxEventAcceleration);
|
||||
Preferences::AddFloatVarCache(&gFlingFriction, "apz.fling_friction", gFlingFriction);
|
||||
Preferences::AddFloatVarCache(&gFlingStoppedThreshold, "apz.fling_stopped_threshold", gFlingStoppedThreshold);
|
||||
Preferences::AddUintVarCache(&gMaxVelocityQueueSize, "apz.max_velocity_queue_size", gMaxVelocityQueueSize);
|
||||
Preferences::AddFloatVarCache(&gMaxVelocity, "apz.max_velocity_pixels_per_ms", gMaxVelocity);
|
||||
}
|
||||
|
||||
class ReadAxisPref MOZ_FINAL : public nsRunnable {
|
||||
@ -90,6 +97,9 @@ Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
|
||||
|
||||
void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, const TimeDuration& aTimeDelta) {
|
||||
float newVelocity = mAxisLocked ? 0 : (mPos - aPos) / aTimeDelta.ToMilliseconds();
|
||||
if (gMaxVelocity > 0.0f) {
|
||||
newVelocity = std::min(newVelocity, gMaxVelocity);
|
||||
}
|
||||
|
||||
mVelocity = newVelocity;
|
||||
mPos = aPos;
|
||||
|
Loading…
Reference in New Issue
Block a user