Repository navigation
v2.1.0-rc.2
Pre-release
Pre-release
Note:
2.1.0introduces a recency-weighted LSQ1 velocity tracker, updatesSwipeRecognizerdefaults (threshold: 30,maxVelocity: 80), and makesRecognizer.requireFailure()strictly one-way (directed) rather than bidirectional. Please test gesture feel and recognizer interactions with this release candidate before2.1.0final.
Features
- Add recency-weighted 1st-order least-squares (LSQ1) velocity tracker with
PointerEvent.getCoalescedEvents()sub-frame sampling (capped at 250Hz) andsrcEvent.timeStampsupport - Preserve sub-pixel pointer positions in
getCenter()andsimpleCloneInputData() - Add optional
pointerTypesarray filtering onManager/Hammer.defaults(e.g.['touch', 'pen']) - Support
pinch-zoominTouchAction(preserving native browser pinch-zoom onpan-x/pan-y) and dynamicCSS.supports('touch-action', ...)validation - Support synchronous
PressRecognizerrecognition without a timer whentime: 0 - Support Shadow DOM targets via
srcEvent.composedPath(),assignedSlot/ShadowRoot.hosttraversal inhasParent(), andcomposed: trueDOM events - Add
maxVelocitycap (80px/ms) and raise defaultthreshold(30px) inSwipeRecognizer
Input
- Continuously unwrap multi-touch
rotationacross the±180°boundary and rebasebaseScale/baseRotationwhen the active pointer pair changes mid-gesture; clear stalefirstMultipleon lift - Self-heal leaked pointers on primary
pointerdown/ fresh multi-touch start and cancel activeMouseInput/PointerEventInputpointers on windowblur - Ignore non-primary mouse/pen buttons on start, handle chorded mouse/pen button release via
ev.buttons, and dedupe bubbledtouchstart/ guard empty touches inSingleTouchInput - Use passive
touchstart/touchmovelisteners when nativetouch-actionhandles scrolling, dynamically rebinding to non-passive only when the JS polyfill is active - Replace per-touch
setTimeoutchurn inTouchMouseInputwith timestamp-based pruning and reset child mouse state on synthetic/overlapping touch - Reset active input state when a manager is dynamically disabled, and guard
NaN/non-finite coords and zerodeltaTime
Recognizers
- Make
Recognizer.requireFailure()one-way (directed) with internal_requiredBycleanup sotap.requireFailure('doubletap')works regardless of registration order and rapid 3+ taps keep firing - Require
STATE_BEGAN/STATE_CHANGEDbefore emittingSTATE_ENDEDinAttrRecognizer - Project swipe velocity onto
offsetDirectioninSwipeRecognizerto reject reverse-flicks and handle curved/diagonal swipes cleanly - Simplify single-axis
PanRecognizerthreshold and direction clamping and remove unusedpX/pYstate - Require
pressto have emitted before firingpressup, invalidate on multi-touch/movement, and claimsession.curRecognizeron press emit - Remove dead
failTimeouttimer churn inTapRecognizer, enforcemaxPointers, and handle staggered multi-pointer tap liftoff - Skip cloning
inputDatawhen a recognizer is statically disabled and guard async timers and secondary emits viaisRecognizerActive()/canContinueEmit()
Manager
- Deduplicate identical handler registrations in
Manager.on()and avoid per-emit closure/slice allocations inManager.emit() - Snapshot
recognizerson mid-cycleadd()/remove(), keepsession.curRecognizerconsistent intry/finally, and clearcurRecognizeron cancel/fail - Batch
touchAction.update()and resolve forwardrecognizeWith/requireFailurereferences in a second pass duringManagerconstruction - Clean up all incoming and outgoing
requireFailureandrecognizeWithlinks onManager.remove()andManager.destroy(), and guard emits/sets afterdestroy()
Touch-action
- Fast-path
TouchAction.preventDefaults()when nativetouch-actionis applied and restore the element's original inlinetouch-actionondestroy() - Validate
touch-actiontokens against an allowlist and store internal lookup maps in prototype-lesscreateMap()dictionaries
Packaging, Build, Tests & CI
- Move UMD export wrapper to
src/hammer.suffix.js, check CommonJS before AMD for CJS+AMD coexistence, guard frozen globals, support Web Workerself, and set"sideEffects": trueandengines.node >= 14.0.0 - Apply license banner before UglifyJS so
hammer.min.js.mapline mappings align - Upgrade to QUnit 3,
grunt-contrib-qunit, andgrunt-eslint(lintingsrc/,tests/,hammer.js, andhammer.min.js); remove vendored QUnit/jQuery/Blanket - Add Node/SSR/UMD verification (
test-ssr) and real browser-trusted CDP multi-touch E2E test suite (test-cdp-touch), and consolidate/deduplicate unit tests