Skip to content

v2.1.0-rc.2

Pre-release
Pre-release

Choose a tag to compare

@jtangelder jtangelder released this 29 Nov 19:07

Note: 2.1.0 introduces a recency-weighted LSQ1 velocity tracker, updates SwipeRecognizer defaults (threshold: 30, maxVelocity: 80), and makes Recognizer.requireFailure() strictly one-way (directed) rather than bidirectional. Please test gesture feel and recognizer interactions with this release candidate before 2.1.0 final.

Features
  • Add recency-weighted 1st-order least-squares (LSQ1) velocity tracker with PointerEvent.getCoalescedEvents() sub-frame sampling (capped at 250Hz) and srcEvent.timeStamp support
  • Preserve sub-pixel pointer positions in getCenter() and simpleCloneInputData()
  • Add optional pointerTypes array filtering on Manager / Hammer.defaults (e.g. ['touch', 'pen'])
  • Support pinch-zoom in TouchAction (preserving native browser pinch-zoom on pan-x / pan-y) and dynamic CSS.supports('touch-action', ...) validation
  • Support synchronous PressRecognizer recognition without a timer when time: 0
  • Support Shadow DOM targets via srcEvent.composedPath(), assignedSlot/ShadowRoot.host traversal in hasParent(), and composed: true DOM events
  • Add maxVelocity cap (80 px/ms) and raise default threshold (30 px) in SwipeRecognizer
Input
  • Continuously unwrap multi-touch rotation across the ±180° boundary and rebase baseScale/baseRotation when the active pointer pair changes mid-gesture; clear stale firstMultiple on lift
  • Self-heal leaked pointers on primary pointerdown / fresh multi-touch start and cancel active MouseInput / PointerEventInput pointers on window blur
  • Ignore non-primary mouse/pen buttons on start, handle chorded mouse/pen button release via ev.buttons, and dedupe bubbled touchstart / guard empty touches in SingleTouchInput
  • Use passive touchstart/touchmove listeners when native touch-action handles scrolling, dynamically rebinding to non-passive only when the JS polyfill is active
  • Replace per-touch setTimeout churn in TouchMouseInput with 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 zero deltaTime
Recognizers
  • Make Recognizer.requireFailure() one-way (directed) with internal _requiredBy cleanup so tap.requireFailure('doubletap') works regardless of registration order and rapid 3+ taps keep firing
  • Require STATE_BEGAN / STATE_CHANGED before emitting STATE_ENDED in AttrRecognizer
  • Project swipe velocity onto offsetDirection in SwipeRecognizer to reject reverse-flicks and handle curved/diagonal swipes cleanly
  • Simplify single-axis PanRecognizer threshold and direction clamping and remove unused pX/pY state
  • Require press to have emitted before firing pressup, invalidate on multi-touch/movement, and claim session.curRecognizer on press emit
  • Remove dead failTimeout timer churn in TapRecognizer, enforce maxPointers, and handle staggered multi-pointer tap liftoff
  • Skip cloning inputData when a recognizer is statically disabled and guard async timers and secondary emits via isRecognizerActive() / canContinueEmit()
Manager
  • Deduplicate identical handler registrations in Manager.on() and avoid per-emit closure/slice allocations in Manager.emit()
  • Snapshot recognizers on mid-cycle add()/remove(), keep session.curRecognizer consistent in try/finally, and clear curRecognizer on cancel/fail
  • Batch touchAction.update() and resolve forward recognizeWith/requireFailure references in a second pass during Manager construction
  • Clean up all incoming and outgoing requireFailure and recognizeWith links on Manager.remove() and Manager.destroy(), and guard emits/sets after destroy()
Touch-action
  • Fast-path TouchAction.preventDefaults() when native touch-action is applied and restore the element's original inline touch-action on destroy()
  • Validate touch-action tokens against an allowlist and store internal lookup maps in prototype-less createMap() 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 Worker self, and set "sideEffects": true and engines.node >= 14.0.0
  • Apply license banner before UglifyJS so hammer.min.js.map line mappings align
  • Upgrade to QUnit 3, grunt-contrib-qunit, and grunt-eslint (linting src/, tests/, hammer.js, and hammer.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