mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Fix dashboard mobile: require press-and-hold to reorder sections
On mobile, swiping through dashboard sections (investments, net worth, balance sheets, etc.) accidentally triggers drag-to-reorder because the hold delay is only 150ms with no movement cancellation. - Increase hold delay from 150ms to 500ms - Cancel drag activation if finger moves >10px before hold triggers, allowing normal scroll gestures to pass through unimpeded Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ export default class extends Controller {
|
|||||||
|
|
||||||
// Short delay to prevent accidental touches on the grip handle
|
// Short delay to prevent accidental touches on the grip handle
|
||||||
static values = {
|
static values = {
|
||||||
holdDelay: { type: Number, default: 150 },
|
holdDelay: { type: Number, default: 500 },
|
||||||
};
|
};
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
@@ -110,11 +110,24 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
touchMove(event) {
|
touchMove(event) {
|
||||||
if (!this.holdActivated || !this.isTouching || !this.draggedElement) return;
|
const touchX = event.touches[0].clientX;
|
||||||
|
const touchY = event.touches[0].clientY;
|
||||||
|
|
||||||
|
// If hold hasn't activated yet, cancel it if user moves too far (they're scrolling)
|
||||||
|
if (!this.holdActivated) {
|
||||||
|
const dx = touchX - this.touchStartX;
|
||||||
|
const dy = touchY - this.touchStartY;
|
||||||
|
if (Math.abs(dx) > 10 || Math.abs(dy) > 10) {
|
||||||
|
this.cancelHold();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isTouching || !this.draggedElement) return;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.currentTouchX = event.touches[0].clientX;
|
this.currentTouchX = touchX;
|
||||||
this.currentTouchY = event.touches[0].clientY;
|
this.currentTouchY = touchY;
|
||||||
|
|
||||||
const afterElement = this.getDragAfterElement(this.currentTouchX, this.currentTouchY);
|
const afterElement = this.getDragAfterElement(this.currentTouchX, this.currentTouchY);
|
||||||
this.clearPlaceholders();
|
this.clearPlaceholders();
|
||||||
|
|||||||
Reference in New Issue
Block a user