Fix iOS Safari double-tap zoom issue on score modification buttons
Problem:
- Rapid tapping on +0.001/-0.001 buttons triggered page zoom on iOS Safari
- Previous solutions (viewport meta, touch-action: manipulation) were ineffective
Solution implemented:
1. Enhanced global touch event handling in index.html:
- Added comprehensive gesture event prevention (gesturestart/change/end)
- Improved touchend debouncing with stopPropagation
- Added specific CSS rules for button elements with touch-action: none
2. Modified button interaction in modify-score.vue:
- Replaced @click events with @touchstart/@touchend handlers
- Added preventDefault and stopPropagation on touch events
- Implemented 100ms debounce to prevent rapid successive touches
- Added pointer-events: none to child elements to ensure touch targets
- Changed touch-action from 'manipulation' to 'none' for complete control
Technical details:
- touch-action: none completely disables browser touch gestures
- Event handlers use { passive: false } to allow preventDefault
- Debounce mechanism prevents accidental double-triggers
- Child elements have pointer-events: none to ensure parent handles all touches
Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
36
index.html
36
index.html
@@ -12,22 +12,52 @@
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
/* 针对按钮元素禁用所有触摸动作 */
|
||||
button, .control-btn, [class*="btn"] {
|
||||
touch-action: none !important;
|
||||
-webkit-user-select: none !important;
|
||||
user-select: none !important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
// 禁用 iOS Safari 双击缩放
|
||||
// 更强力的 iOS Safari 双击缩放禁用方案
|
||||
(function() {
|
||||
var lastTouchEnd = 0;
|
||||
var lastTouchTarget = null;
|
||||
|
||||
// 阻止快速连续触摸导致的缩放
|
||||
document.addEventListener('touchend', function(event) {
|
||||
var now = Date.now();
|
||||
if (now - lastTouchEnd <= 300) {
|
||||
var timeSinceLastTouch = now - lastTouchEnd;
|
||||
|
||||
// 如果两次触摸间隔小于 300ms,阻止默认行为
|
||||
if (timeSinceLastTouch <= 300 && timeSinceLastTouch > 0) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
lastTouchEnd = now;
|
||||
lastTouchTarget = event.target;
|
||||
}, { passive: false });
|
||||
|
||||
// 禁用双击缩放
|
||||
// 阻止双击事件
|
||||
document.addEventListener('dblclick', function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}, { passive: false });
|
||||
|
||||
// 阻止手势缩放
|
||||
document.addEventListener('gesturestart', function(event) {
|
||||
event.preventDefault();
|
||||
}, { passive: false });
|
||||
|
||||
document.addEventListener('gesturechange', function(event) {
|
||||
event.preventDefault();
|
||||
}, { passive: false });
|
||||
|
||||
document.addEventListener('gestureend', function(event) {
|
||||
event.preventDefault();
|
||||
}, { passive: false });
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user