Upgrade Guide
From 2.x to 3.0
EventManager
no longer comes with a default set of recognizers. Specifyoptions.recognizers
to emit gesture events.EventManager
'srecognizerOptions
prop is removed.- Element must be supplied when constructing
EventManager
and cannot be reassigned. To change the event target, destroy the existing event manager instance and construct a new one. - Hammer.js is no longer a dependency. Due to the lack of maintenance on the legacy hammerjs project, mjolnir.js has ported it to TypeScript and incorporated it into the code base. To configure recognizers (Pan, Pinch etc.), directly import them from
mjolnir.js
. For details, see the documentation of each recognizer.
Before:
v2
import Hammer from 'hammer.js';
import {EventManager} from 'mjolnir.js';
new EventManager(document.body, {
recognizers: [
[Hammer.Pan, {threshold: 4, direction: Hammer.DIRECTION_HORIZONTAL}],
[Hammer.Tap, {event: 'doubletap', pointers: 2}],
[Hammer.Tap, {event: 'singletap'}, null, 'doubletap']
]
});
After:
v3
import {EventManager, Pan, Tap, InputDirection} from 'mjolnir.js';
new EventManager(document.body, {
recognizers: [
[Pan, {threshold: 4, direction: InputDirection.Horizontal}],
[Tap, {event: 'doubletap', pointers: 2}],
[Tap, {event: 'singletap'}, null, 'doubletap']
]
});
From 1.x to 2.0
- The
legacyBlockScroll
option toEventManager
is removed. UseeventManager.on('wheel', evt => evt.preventDefault())
to block scrolling. - The
rightButton
option toEventManager
is removed. UseeventManager.on('contextmenu', evt => evt.preventDefault())
to enable right-button clicking and dragging.