mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Reduce hold delay to 800ms and prevent text selection during hold
1000ms was long enough to trigger browser text selection before drag activated. Reduced to 800ms and added userSelect:none on the section during the touch hold period, restored when touch ends. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ export default class extends Controller {
|
|||||||
|
|
||||||
// Hold delay to require deliberate press-and-hold before activating drag mode
|
// Hold delay to require deliberate press-and-hold before activating drag mode
|
||||||
static values = {
|
static values = {
|
||||||
holdDelay: { type: Number, default: 1000 },
|
holdDelay: { type: Number, default: 800 },
|
||||||
};
|
};
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
@@ -98,6 +98,10 @@ export default class extends Controller {
|
|||||||
this.currentTouchY = this.touchStartY;
|
this.currentTouchY = this.touchStartY;
|
||||||
this.holdActivated = false;
|
this.holdActivated = false;
|
||||||
|
|
||||||
|
// Prevent text selection while waiting for hold to activate
|
||||||
|
section.style.userSelect = "none";
|
||||||
|
section.style.webkitUserSelect = "none";
|
||||||
|
|
||||||
// Start hold timer
|
// Start hold timer
|
||||||
this.holdTimer = setTimeout(() => {
|
this.holdTimer = setTimeout(() => {
|
||||||
this.activateDrag();
|
this.activateDrag();
|
||||||
@@ -183,6 +187,16 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetTouchState() {
|
resetTouchState() {
|
||||||
|
// Restore text selection
|
||||||
|
if (this.pendingSection) {
|
||||||
|
this.pendingSection.style.userSelect = "";
|
||||||
|
this.pendingSection.style.webkitUserSelect = "";
|
||||||
|
}
|
||||||
|
if (this.draggedElement) {
|
||||||
|
this.draggedElement.style.userSelect = "";
|
||||||
|
this.draggedElement.style.webkitUserSelect = "";
|
||||||
|
}
|
||||||
|
|
||||||
this.isTouching = false;
|
this.isTouching = false;
|
||||||
this.draggedElement = null;
|
this.draggedElement = null;
|
||||||
this.pendingSection = null;
|
this.pendingSection = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user