Yet another minimalistic tap&hold implementation with circle effect.
import tmihold from 'tmihold.mjs'; // default
const remover = tmihold(Element el, Function cb, any ...args);
el
is target element, cb
is callback function, ...args
are optional arguments for callback.
Returned value (remover
) is a function that removes all event listeners created by this call.
If cb
is null
or omitted, it returns a Promise which is resolved by tap&hold.
On resolve, event listeners are removed; so the event is fired only once. Result is el
, rest ...args
are ignored.
const elem = await tmihold(getElementById('elem_id'));
// or
tmihold(getElementById('elem_id')).then(elem => {/* ... */});
Default target element is document
.
Tap behaviour, duration and effect id are hardcoded.
Circle animation is implemented with conic gradient as mask-image
. As of September 2021, it's prefixed for WebKit and doesn't seem to work in Gecko. Whatever.