I need to create a 'select by hover' (dwell) effect in my application and it is crucial to be timely and accurate. This needs to trigger just once for every timeout call and must not loop. The dwell function is attached to an element (getElementById).
My implementation at the moment sometimes works brilliantly and sometimes takes a lot of time to complete. Sometimes the callback just doesn't trigger after the setTimeout.
dwell: (elem, select) => {
var timeout = 0
elem.onmouseover = () => {
timeout = setTimeout(select, dwellTime)
}
elem.onmouseout = () => {
clearTimeout(timeout)
}
}
The select callback function must execute EXACTLY after the dwellTime has elapsed. Any ideas please?