From 407b3b494d1e5b95b01d34c9464874ceee2015df Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Mon, 23 Jan 2023 11:20:10 +0100 Subject: [PATCH] next pinch applied (lack of feedback is confusing) --- index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.html b/index.html index 7dd739f..d5c884d 100644 --- a/index.html +++ b/index.html @@ -2176,6 +2176,21 @@ function changeColorLastId(){ if (id) document.querySelector("#"+id).setAttribute("color", "red") } +function changeColorNextPinch(){ + //let id = getIdFromPick() // applies on primary only + // does not work anymore ... but could listen to selectedElements changes via an observer but deprecated + // proxy could be nice but requires to modify push() calls first + let lastPrimary = selectedElements.filter( e => e.primary ).length + + let checkForNewPinches = setInterval( _ => { + if (selectedElements.filter( e => e.primary ).length > lastPrimary){ + let id = getIdFromPick() // applies on primary only + if (id) document.querySelector("#"+id).setAttribute("color", "red") + clearInterval(checkForNewPinches) + } + }, 50) // relatively cheap check, filtering on small array +} + /* generalize selector to pick last Nth rather than very last @@ -2256,6 +2271,7 @@ consider pick then apply, i.e changeColorLastId() but for next Id +