feat: Add swipe gesture support for workspace navigation

This commit is contained in:
mr. M
2024-11-09 13:50:03 +01:00
parent 5c7dc3097a
commit 31cc0ce7a8

View File

@@ -40,10 +40,36 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
await this.initializeWorkspaces();
console.info('ZenWorkspaces: ZenWorkspaces initialized');
const toolbox = document.getElementById('navigator-toolbox');
toolbox.addEventListener('MozSwipeGestureStart', this.handleSwipeGestureStart.bind(this));
toolbox.addEventListener('MozSwipeGestureEnd', this.handleSwipeGestureEnd.bind(this));
toolbox.addEventListener('MozSwipeGesture', this.handleSwipeGesture.bind(this));
// Add observer for sync completion
Services.obs.addObserver(this, 'weave:engine:sync:finish');
}
handleSwipeGestureStart(event) {
// We can move to the right or left
const direction = event.direction;
if (direction === 'right' || direction === 'left') {
this._swipeGestureDirection = direction;
event.preventDefault();
event.stopPropagation();
}
}
handleSwipeGestureEnd(event) {
if (!this._swipeGestureDirection) {
return;
}
this.changeWorkspaceShortcut(this._swipeGestureDirection === 'right' ? 1 : -1);
this._swipeGestureDirection = null;
}
handleSwipeGesture(event) {
}
get activeWorkspace() {
return this._activeWorkspace;
}