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>
This commit is contained in:
parent
df4c05f834
commit
3c1074085e
@ -635,6 +635,9 @@ var SwipeTracker = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getBounds(pos) {
|
_getBounds(pos) {
|
||||||
|
if (this.allowLongSwipes)
|
||||||
|
return [this._snapPoints[0], this._snapPoints[this._snapPoints.length - 1]];
|
||||||
|
|
||||||
const closest = this._findClosestPoint(pos);
|
const closest = this._findClosestPoint(pos);
|
||||||
|
|
||||||
let prev, next;
|
let prev, next;
|
||||||
@ -667,11 +670,7 @@ var SwipeTracker = GObject.registerClass({
|
|||||||
this._progress += delta / distance;
|
this._progress += delta / distance;
|
||||||
this._history.append(time, delta);
|
this._history.append(time, delta);
|
||||||
|
|
||||||
const [lower, upper] = this.allowLongSwipes
|
this._progress = Math.clamp(this._progress, ...this._getBounds(this._initialProgress));
|
||||||
? [this._snapPoints[0], this._snapPoints[this._snapPoints.length - 1]]
|
|
||||||
: this._getBounds(this._initialProgress);
|
|
||||||
|
|
||||||
this._progress = Math.clamp(this._progress, lower, upper);
|
|
||||||
|
|
||||||
this.emit('update', this._progress);
|
this.emit('update', this._progress);
|
||||||
}
|
}
|
||||||
@ -701,8 +700,6 @@ var SwipeTracker = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
pos = pos * Math.sign(velocity) + this._progress;
|
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);
|
const index = this._findPointForProjection(pos, velocity);
|
||||||
|
Loading…
Reference in New Issue
Block a user