[gnome-shell/wip/exalm/swipes: 4/5] swipeTracker: Clamp position when long swipes are enabled too
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/exalm/swipes: 4/5] swipeTracker: Clamp position when long swipes are enabled too
- Date: Sat, 13 Mar 2021 18:08:26 +0000 (UTC)
commit 3c1074085e1b507f597c8185d6a0e5e2a0f53c22
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Mon Mar 1 22:39:48 2021 +0500
swipeTracker: Clamp position when long swipes are enabled too
Avoid wrapping back to the first page when swiping forward from the last
page.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1731>
js/ui/swipeTracker.js | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js
index a68e93b822..8f80bfb3e3 100644
--- a/js/ui/swipeTracker.js
+++ b/js/ui/swipeTracker.js
@@ -635,6 +635,9 @@ var SwipeTracker = GObject.registerClass({
}
_getBounds(pos) {
+ if (this.allowLongSwipes)
+ return [this._snapPoints[0], this._snapPoints[this._snapPoints.length - 1]];
+
const closest = this._findClosestPoint(pos);
let prev, next;
@@ -667,11 +670,7 @@ var SwipeTracker = GObject.registerClass({
this._progress += delta / distance;
this._history.append(time, delta);
- const [lower, upper] = this.allowLongSwipes
- ? [this._snapPoints[0], this._snapPoints[this._snapPoints.length - 1]]
- : this._getBounds(this._initialProgress);
-
- this._progress = Math.clamp(this._progress, lower, upper);
+ this._progress = Math.clamp(this._progress, ...this._getBounds(this._initialProgress));
this.emit('update', this._progress);
}
@@ -701,9 +700,7 @@ var SwipeTracker = GObject.registerClass({
}
pos = pos * Math.sign(velocity) + this._progress;
-
- if (!this.allowLongSwipes)
- pos = Math.clamp(pos, ...this._getBounds(this._initialProgress));
+ pos = Math.clamp(pos, ...this._getBounds(this._initialProgress));
const index = this._findPointForProjection(pos, velocity);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]