npm hammerjs 2.1.0-rc.6
v2.1.0-rc.6

one hour ago

Migration notes (2.0.x → 2.1.0):

  • All existing 2.x instance/session property names are preserved unmangled in hammer.js and hammer.min.js (the _-prefixing and UglifyJS mangle.properties changes from 2.1.0-rc.5 were reverted for SemVer compatibility).
  • session.curRecognizer has been replaced by pairwise blocking (isBlockingRecognizer() / isBlocked()).
  • Recognizer.requireFailure() is now strictly one-way (directed), and Recognizer.dropRecognizeWith() is symmetric (removes the link from both recognizers).
  • Velocity tracking now uses recency-weighted 1st-order least-squares (LSQ1) with PointerEvent.getCoalescedEvents() sub-frame sampling, and SwipeRecognizer defaults are updated (threshold: 30, maxVelocity: 80).
  • Hammer.QuickScale (enable: false) is appended at Hammer.defaults.preset[7], preserving 2.0.x preset indices 0..6.
  • Coordinate @types/hammerjs 2.1 definitions (QuickScale, STATE_PENDING, pointerTypes, maxVelocity, recognizers: false) when publishing 2.1.0 final.
SemVer Compatibility Restored
  • Revert the 29 _-prefixed internal property renames and disable UglifyJS mangle.properties introduced in 2.1.0-rc.5, restoring domHandler, handlers, oldCssProps, id, simultaneous, requireFail, pTime, pCenter, count, store, pressed, lastEv, targetIds, started, lastTouches, appliedNative, oldTouchAction, session.prevInput, firstMultiple, offsetDelta, prevDelta, stopped, prevented, startTime, and velocitySamples (7f02714)
  • Move [QuickScaleRecognizer, { enable: false }] from Hammer.defaults.preset[2] to index 7 so 2.0.x preset indices 0..6 remain unchanged
Security & Runtime Hardening
  • QuickScale & non-native touch-action (document/window): Defer non-passive → passive touch listener downgrades (_pendingTouchSync) until isFinal so mid-session QuickScale disarming never drops active pointers or swallows distant taps/Press; guard null _anchor in emit(), sensitivity === 0 (returns scale 1), and backward timeStamp on the second tap
  • Recognizer linking & state machine: Restore instanceof Recognizer check in getRecognizerByNameIfManager() (preventing unresolved strings on unattached recognizers from corrupting requireFail / simultaneous); reject self-links (other !== this) in recognizeWith() / requireFailure(); restore canContinueEmit() checks across Recognizer.emit() and SwipeRecognizer.emit(); emit synthetic STATE_CANCELLED (isFirst: false, isFinal: false, stripping the winner's additionalEvent) for active continuous _requiredBy dependents before resetting, snapshotting _requiredBy.slice() against mutation
  • Re-entrancy & listener throws: Add canContinueAfterCancel() guards after cancel emits in TouchMouseInput and PointerEventInput primary-pointer purges; wrap isFinal recognition and hammer.input emits in try/finally so throwing listeners still reset unvisited recognizers/timers (Press, QuickScale) and flush _pendingTouchSync; snapshot manager/session around enable callbacks and process() in Recognizer.recognize() and re-check manager/element/stopped in isRecognizerActive()
  • Manager & UMD safety: Early-return on post-destroy() set(), add(), on(), and emit(); guard undefined arguments in on()/off(); guard missing target.dispatchEvent in triggerDomEvent(); restore try { window[exportName] = Hammer; } catch (e) {} and null-safe window/document/module/navigator checks for frozen globals and non-browser SSR sandboxes
  • DOM clobbering & prototype pollution: Cache native DOM prototype getters (nodeType, parentNode, ownerDocument, assignedSlot, defaultView, host) in hasParent() and getWindowForElement() (handling slotted Text nodes and same-origin iframes); use null-prototype maps (Object.create(null)) for handlers, oldCssProps, TOUCH_ACTION_MAP, TOUCH_INPUT_MAP, POINTER_INPUT_MAP, MOUSE_INPUT_MAP, targetIds, and activeIds; reject '' and Object.prototype keys in prefixed()
  • Touch-action & velocity: Attach an auxiliary non-passive touchmove fallback listener on PointerEventInput when SUPPORT_TOUCH && !appliedNative && _flags; prioritize pinch-zoom over pan-x/pan-y in cleanTouchActions() even without native support; schedule/cancel iOS WebKit requestAnimationFrame commits on the element's owning window (getWindowForElement) with a function guard; restore dt < -VELOCITY_HORIZON_MS backward-jump resets in src/velocity.js and non-negative wall-clock clamps (deltaTime, Tap, Press, QuickScale)
  • Manual test pages: Fix nested.html cross-manager requireFailure(), replace innerHTML with safe DOM APIs in simulator.html / input.html, and drop cleartext http:// asset URLs
  • Built bundles: hammer.js 144.48 kB → hammer.min.js 35.80 kB (12.31 kB gzip, 11.11 kB brotli); hammer.mjs 146.42 kB → hammer.min.mjs 37.15 kB (12.72 kB gzip, 11.37 kB brotli); hammer.node.mjs 2.32 kB — all with unmangled 2.x property names
CI/CD, Tooling & Testing
  • Harden .github/workflows/{ci,release,fuzz,ios}.yml with npm ci --ignore-scripts, scoped permissions, concurrency group in fuzz.yml, 7-day artifact retention, and 7-day Dependabot cooldowns; pin ios.yml to appium@4.0.2, xcuitest@13.8.6, and SHA-256-verified prebuilt appium-webdriveragent@17.2.1 plus a fuzz_seed workflow_dispatch input (3369a4a)
  • Enable "noUnusedLocals": true in tsconfig.json; reject non-numeric FUZZ_SEED values in vitest.config.mjs and tests/ios/ios_safari.test.js; seed npm run test:coverage (FUZZ_SEED=${FUZZ_SEED:-20261204}); add "quickscale" and "zoom" package keywords
  • Fix t=0 timestamp clamping in runSyntheticTouchTrace(), triggerSyntheticPoints(), and coalesced fuzz events (and forward-port runSyntheticTrace timestamp fixes to 3.0.0); stabilize CDP fast-swipe E2E test with explicit monotonic CDP timestamps; replace unconditional second-click retry in real_pointer.test.js with an explicit WebKit omitted-pointerdown resync; test all built UMD (hammer.js, hammer.min.js) and ESM (hammer.mjs, hammer.min.mjs) bundles across real browser gestures
  • Convert all 21 remaining setTimeout Promise unit tests (plus gestures.test.js and nested_recognizers.test.js) to deterministic Vitest fake timers
  • Add standalone hammer.mjs and minified hammer.min.mjs (+ hammer.min.mjs.map) ES module bundles (default + all static named exports, preserving window.Hammer for 2.x import 'hammerjs' compatibility), plus a tiny hammer.node.mjs wrapper under exports['.'].node.import eliminating Node mixed require/import dual-package instance splits, wired via "type": "commonjs", "module", and a backwards-compatible "exports" map preserving legacy 2.x subpaths (./hammer, ./hammer.js, ./hammer.min.js, ./src/*, ./package.json)
  • Make build banner dates deterministic UTC with strict SOURCE_DATE_EPOCH support in scripts/build.mjs, normalize repository.url to git+https://... (0 publint errors/warnings/suggestions), and declare vite explicitly in devDependencies for npm run test:manual
  • Modernize tests/manual/ for iOS Safari & Android Chrome (adding index.html hub, quick_scale.html, velocity_swipe.html, multitouch_edge.html, edge_cases.html with live self-checks, bundle switcher for hammer.js/hammer.min.js/hammer.mjs/hammer.min.mjs, driver override, and npm run test:manual Vite LAN dev server with src/ watch rebuilds)
  • Add package-lock.json sync, unmangled hammer.min.js 2.x property checks, frozen/null global UMD sandbox tests, and tests/unit/regressions.test.js covering all hardening fixes and exact boundary/pen conditions (c54da3c)

Full Changelog: v2.1.0-rc.5...v2.1.0-rc.6

Don't miss a new hammerjs release

NewReleases is sending notifications on new releases.