mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-08 10:56:36 +00:00
Started using force calculations when swiping between workspaces
This commit is contained in:
@@ -393,17 +393,23 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const delta = event.delta * 300;
|
const delta = event.delta * 300 + 1;
|
||||||
this._swipeState.lastDelta = delta;
|
const stripWidth = document.getElementById('tabbrowser-tabs').scrollWidth;
|
||||||
|
let translateX = this._swipeState.lastDelta + delta;
|
||||||
|
// Add a force multiplier as we are translating the strip depending on how close to the edge we are
|
||||||
|
let forceMultiplier = Math.min(1, 1 - (Math.abs(translateX) / (stripWidth * 1.5)));
|
||||||
|
if (forceMultiplier > 0.5) {
|
||||||
|
translateX *= forceMultiplier;
|
||||||
|
this._swipeState.lastDelta = delta;
|
||||||
|
} else {
|
||||||
|
translateX = this._swipeState.lastDelta;
|
||||||
|
}
|
||||||
|
|
||||||
if (Math.abs(delta) > 1) {
|
if (Math.abs(delta) > 1) {
|
||||||
this._swipeState.direction = delta > 0 ? 'left' : 'right';
|
this._swipeState.direction = delta > 0 ? 'left' : 'right';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply a translateX to the tab strip to give the user feedback on the swipe
|
// Apply a translateX to the tab strip to give the user feedback on the swipe
|
||||||
const stripWidth = document.getElementById('tabbrowser-tabs').scrollWidth;
|
|
||||||
const translateX = Math.max(-stripWidth, Math.min(delta, stripWidth));
|
|
||||||
|
|
||||||
const currentWorkspace = this.activeWorkspace;
|
const currentWorkspace = this.activeWorkspace;
|
||||||
this._organizeWorkspaceStripLocations({ uuid: currentWorkspace }, true, translateX);
|
this._organizeWorkspaceStripLocations({ uuid: currentWorkspace }, true, translateX);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user