Observe Element(s)
Add
To watch for wheel gestures on an element, add the element with .observe to the WheelGestures instance:
const wheelGestures = WheelGestures()
const domElement = document.getElementById("wheel-movable")
wheelGestures.observe(domElement)
Remove
When you are ready to cleanup the event listeners you can call .unobserve
method with the same element.
wheelGestures.unobserve(domElement)
Alternatively you can call the function returned from .observe()
const unobserveDomElement = wheelGestures.observe(domElement)
// later in clean up...
unobserveDomElement()
Alternative: Add events manually
If you prefer to add & remove event listeners yourself, you can also feed events to WheelGestures to process manually:
const wheelGestures = WheelGestures()
const domElement = document.getElementById("wheel-movable")
domElement.addEventListener("wheel", wheelGestures.feedWheel)