mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 03:46:37 +01:00
fix(mobile): sidebar randomly showing on taps
This commit is contained in:
@@ -33,12 +33,12 @@ export default class SidebarContainer extends FlexContainer {
|
|||||||
|
|
||||||
#onDragStart(e) {
|
#onDragStart(e) {
|
||||||
const x = e.touches ? e.touches[0].clientX : e.clientX;
|
const x = e.touches ? e.touches[0].clientX : e.clientX;
|
||||||
|
this.startX = x;
|
||||||
|
|
||||||
if (x > 30 && this.currentTranslate === -100) {
|
if (x > 30 && this.currentTranslate === -100) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startX = x;
|
|
||||||
this.#setInitialState();
|
this.#setInitialState();
|
||||||
this.dragState = DRAG_STATE_INITIAL_DRAG;
|
this.dragState = DRAG_STATE_INITIAL_DRAG;
|
||||||
this.translatePercentage = 0;
|
this.translatePercentage = 0;
|
||||||
@@ -52,7 +52,7 @@ export default class SidebarContainer extends FlexContainer {
|
|||||||
const x = e.touches ? e.touches[0].clientX : e.clientX;
|
const x = e.touches ? e.touches[0].clientX : e.clientX;
|
||||||
const deltaX = x - this.startX;
|
const deltaX = x - this.startX;
|
||||||
if (this.dragState === DRAG_STATE_INITIAL_DRAG) {
|
if (this.dragState === DRAG_STATE_INITIAL_DRAG) {
|
||||||
if (Math.abs(deltaX) > 5) {
|
if (Math.abs(deltaX) > 10) {
|
||||||
/* Disable the transitions since they affect performance, they are going to reenabled once drag ends. */
|
/* Disable the transitions since they affect performance, they are going to reenabled once drag ends. */
|
||||||
this.sidebarEl.style.transition = "none";
|
this.sidebarEl.style.transition = "none";
|
||||||
this.backdropEl.style.transition = "none";
|
this.backdropEl.style.transition = "none";
|
||||||
@@ -78,6 +78,11 @@ export default class SidebarContainer extends FlexContainer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.dragState === DRAG_STATE_INITIAL_DRAG) {
|
||||||
|
this.dragState = DRAG_STATE_NONE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the sidebar is closed, snap the sidebar open only if the user swiped over a threshold.
|
// If the sidebar is closed, snap the sidebar open only if the user swiped over a threshold.
|
||||||
// When the sidebar is open, always close for a smooth experience.
|
// When the sidebar is open, always close for a smooth experience.
|
||||||
const isOpen = (this.currentTranslate === -100 && this.translatePercentage > -(100 - DRAG_THRESHOLD));
|
const isOpen = (this.currentTranslate === -100 && this.translatePercentage > -(100 - DRAG_THRESHOLD));
|
||||||
|
|||||||
Reference in New Issue
Block a user