Static
createCreates a new instance of GestureWatcher with the given GestureWatcherConfig. It does not save it for future reuse.
Static
reuseReturns an existing instance of GestureWatcher with the given GestureWatcherConfig, or creates a new one.
NOTE: It saves it for future reuse, so don't use this for temporary short-lived watchers.
Readonly
noRemoves a previously added handler for trackGesture.
Readonly
offRemoves a previously added handler.
Readonly
onCall the given handler whenever the user performs a gesture on the target matching the given options.
IMPORTANT: The same handler can not be added multiple times for the same event target, even if the options differ. If the handler has already been added for this target, either using onGesture or trackGesture, then it will be removed and re-added with the current options.
LisnUsageError If the options are invalid.
Readonly
trackThis is the same as onGesture except that if handler
is not
given, then it defaults to an internal handler that updates a set of CSS
variables on the target's style:
--lisn-js--<Intent>-delta-x
--lisn-js--<Intent>-delta-y
--lisn-js--<Intent>-delta-z
where and <Intent>
is one of GestureIntent and the delta X, Y
and Z are the total summed up deltaX
, deltaY
and deltaZ
since the
callback was added, summed over all devices used (key, touch, etc).
IMPORTANT: The same handler can not be added multiple times for the same target, even if the options differ. If the handler has already been added for this target, either using trackGesture or using onGesture, then it will be removed and re-added with the current options.
LisnUsageError If the options are invalid.
GestureWatcher listens for user gestures resulting from wheel, pointer, touch or key input events.
It supports scroll, zoom or drag type gestures.
It manages registered callbacks globally and reuses event listeners for more efficient performance.