Füge Unterstützung für sofortige Auswahl hinzu, wenn mehr als 3 Finger erkannt werden
This commit is contained in:
@@ -3,6 +3,7 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||
const touches = new Map(); // id -> {el,x,y}
|
||||
let selecting = false;
|
||||
let selectionDone = false;
|
||||
let selectionTimer = null;
|
||||
|
||||
function createFinger(t){
|
||||
const id = (t.identifier !== undefined && t.identifier !== null) ? String(t.identifier) : ('m'+Date.now());
|
||||
@@ -102,6 +103,8 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||
}
|
||||
|
||||
function cancelSelection(){
|
||||
clearTimeout(selectionTimer);
|
||||
selectionTimer = null;
|
||||
selecting = false;
|
||||
selectionDone = false;
|
||||
for(const entry of touches.values()){ entry.el.classList.remove('highlight','lost','winner','pulse'); entry.el.style.opacity = '1'; }
|
||||
@@ -123,8 +126,10 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||
e.preventDefault();
|
||||
const changed = Array.from(e.changedTouches || []);
|
||||
changed.forEach(t=>createFinger(t));
|
||||
cancelSelection();
|
||||
startSelectionIfNeeded();
|
||||
if(!selectionDone){
|
||||
clearTimeout(selectionTimer);
|
||||
selectionTimer = setTimeout(startSelectionIfNeeded, 700);
|
||||
}
|
||||
}, {passive:false});
|
||||
stage.addEventListener('touchmove', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user