diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js index a78fb2898..21cf2cbae 100644 --- a/js/ui/swipeTracker.js +++ b/js/ui/swipeTracker.js @@ -647,6 +647,11 @@ export const SwipeTracker = GObject.registerClass({ return [this._snapPoints[lowerIndex], this._snapPoints[upperIndex]]; } + _getBoundsWithBumpRange(pos) { + const bounds = this._getBounds(pos); + return [bounds[0] - this._bumpRange, bounds[1] + this._bumpRange]; + } + _updateGesture(gesture, time, delta, distance) { if (this._state !== State.SCROLLING) return; @@ -663,7 +668,7 @@ export const SwipeTracker = GObject.registerClass({ this._progress += delta / distance; this._history.append(time, delta); - this._progress = Math.clamp(this._progress, ...this._getBounds(this._initialProgress)); + this._progress = Math.clamp(this._progress, ...this._getBoundsWithBumpRange(this._initialProgress)); this.emit('update', this._progress); } @@ -758,13 +763,16 @@ export const SwipeTracker = GObject.registerClass({ * @param {number[]} snapPoints - An array of snap points, sorted in ascending order * @param {number} currentProgress - initial progress value * @param {number} cancelProgress - the value to be used on cancelling + * @param {number} bumpRange - how much the user can stretch beyond the first or + * the latest snap point */ - confirmSwipe(distance, snapPoints, currentProgress, cancelProgress) { + confirmSwipe(distance, snapPoints, currentProgress, cancelProgress, bumpRange = 0) { this.distance = distance; this._snapPoints = snapPoints; this._initialProgress = currentProgress; this._progress = currentProgress; this._cancelProgress = cancelProgress; + this._bumpRange = bumpRange; this._state = State.SCROLLING; } diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js index b278113e2..c7790c6e1 100644 --- a/js/ui/workspaceAnimation.js +++ b/js/ui/workspaceAnimation.js @@ -14,6 +14,7 @@ import * as Util from '../misc/util.js'; import * as Main from './main.js'; const WINDOW_ANIMATION_TIME = 250; +const WORKSPACE_BUMP_RANGE = 0.1; export const WORKSPACE_SPACING = 100; export const WorkspaceGroup = GObject.registerClass( @@ -477,7 +478,7 @@ export class WorkspaceAnimationController { this._switchData.baseMonitorGroup = monitorGroup; - tracker.confirmSwipe(baseDistance, points, progress, cancelProgress); + tracker.confirmSwipe(baseDistance, points, progress, cancelProgress, WORKSPACE_BUMP_RANGE); } _switchWorkspaceUpdate(tracker, progress) {