New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mjolnir.js

Package Overview
Dependencies
Maintainers
11
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mjolnir.js - npm Package Compare versions

Comparing version

to
2.2.0-beta.1

dist/es5/constants.js

29

CHANGELOG.md
# Change Log
#### [2.3.0] - Aug 2, 2019
- Use ocular-dev-tools (#43)
- Add EventManager.once (#46)
#### [2.2.2] - June 5, 2019
- Fix undefind userAgent (#40)
#### [2.1.1] - Jun 3, 2019
- fix bug where tap threshold is not working (#36)
#### [2.1.0] - Feb 20, 2019
- add anyclick event (#32)
#### [2.0.3] - Jan 8, 2018
- Remove passive event listener warning in Chrome (#31)
#### [2.0.2] - Dec 18, 2018
- Avoid crash if imported in a web worker (#29)
#### [2.0.1] - Nov 9, 2018
- add support for pointerover, pointerout events (#25)

@@ -23,8 +34,11 @@ - fix node 9+ support (#27)

#### [2.0.0] - Oct 31, 2018
- Deprecate `legacyBlockScroll` and `rightButton` options
#### [2.0.0-alpha.3] - Sep 26, 2018
- Add `event.stopImmediatePropagation` (#26)
- Add `event.stopImmediatePropagation` (#26)
#### [2.0.0-alpha.2] - Sep 24, 2018
- Refactor event handling (#23)

@@ -34,8 +48,11 @@ - Fix dblclick delay (#24)

#### [2.0.0-alpha.1] - Sep 24, 2018
- NEW: Provide static browser/node targets (#22)
#### [1.2.2] - Sep 12, 2018
- FIX: Remove commonjs to fix the problem with cjs/esm interop (#20)
#### [1.2.0] - Jun 13, 2018
- NEW: A new option `touchAction` to EventManager that allows users to customize browser touch actions

@@ -45,5 +62,7 @@ - NEW: Supports new event `contextmenu`

#### [1.1.0] - Apr 18, 2018
- NEW: A new option `legacyBlockScroll` to EventManager that allows users to restore the default scroll behavior on wheel events
#### [1.0.1] - Jan 29, 2018
- FIX: Missing `dist-es6` in package

@@ -54,11 +73,15 @@

#### [1.0.0-alpha.2] - Dec 9, 2017
- FIX: EventManager.destroy throws error if element is empty (#9)
#### [1.0.0-alpha.1] - Dec 4, 2017
- NEW: Make DOM element optional in EventManager constructor (#8)
- NEW: Make DOM element optional in EventManager constructor (#8)
#### [0.4.1] - Nov 9, 2017
- FIX: test failure under Node
#### [0.4.0] - Oct 13, 2017
- Only fire keyboard events within the target element (#4)

@@ -68,2 +91,3 @@ - Add flags for mouse buttons to event object (#5)

#### [0.3.0] - Oct 12, 2017
- Support right mouse button gestures (#2)

@@ -73,2 +97,3 @@ - Block click event if double clicking (#3)

#### [0.2.0] - Oct 5, 2017
- Add propagation system (#1)

61

dist/esm/constants.js

@@ -1,23 +0,2 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Hammer from './utils/hammer'; // This module contains constants that must be conditionally required
// due to `window`/`document` references downstream.
import Hammer from './utils/hammer';
export var RECOGNIZERS = Hammer ? [[Hammer.Rotate, {

@@ -38,4 +17,3 @@ enable: false

enable: false
}], // TODO - rename to 'tap' and 'singletap' in the next major release
[Hammer.Tap, {
}], [Hammer.Tap, {
event: 'anytap',

@@ -45,4 +23,3 @@ enable: false

enable: false
}]] : null; // Recognize the following gestures even if a given recognizer succeeds
}]] : null;
export var RECOGNIZER_COMPATIBLE_MAP = {

@@ -53,15 +30,6 @@ rotate: ['pinch'],

anytap: ['tap']
}; // Recognize the folling gestures only if a given recognizer fails
};
export var RECOGNIZER_FALLBACK_MAP = {
doubletap: ['tap']
};
/**
* Only one set of basic input events will be fired by Hammer.js:
* either pointer, touch, or mouse, depending on system support.
* In order to enable an application to be agnostic of system support,
* alias basic input events into "classes" of events: down, move, and up.
* See `_onBasicInput()` for usage of these aliases.
*/
export var BASIC_EVENT_ALIASES = {

@@ -81,14 +49,4 @@ pointerdown: 'pointerdown',

MOUSE_EVENTS: ['mousedown', 'mousemove', 'mouseup', 'mouseover', 'mouseout', 'mouseleave'],
WHEEL_EVENTS: [// Chrome, Safari
'wheel', // IE
'mousewheel', // legacy Firefox
'DOMMouseScroll']
WHEEL_EVENTS: ['wheel', 'mousewheel', 'DOMMouseScroll']
};
/**
* "Gestural" events are those that have semantic meaning beyond the basic input event,
* e.g. a click or tap is a sequence of `down` and `up` events with no `move` event in between.
* Hammer.js handles these with its Recognizer system;
* this block maps event names to the Recognizers required to detect the events.
*/
export var EVENT_RECOGNIZER_MAP = {

@@ -126,8 +84,2 @@ tap: 'tap',

};
/**
* Map gestural events typically provided by browsers
* that are not reported in 'hammer.input' events
* to corresponding Hammer.js gestures.
*/
export var GESTURE_EVENT_ALIASES = {

@@ -143,2 +95,3 @@ click: 'tap',

mouseleave: 'pointerleave'
};
};
//# sourceMappingURL=constants.js.map
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Hammer from './utils/hammer';

@@ -32,20 +13,10 @@ import HammerManagerMock from './utils/hammer-manager-mock';

var DEFAULT_OPTIONS = {
// event handlers
events: null,
// custom recognizers
recognizers: null,
recognizerOptions: {},
// Manager class
Manager: Hammer ? Hammer.Manager : HammerManagerMock,
// allow browser default touch action
// https://github.com/uber/react-map-gl/issues/506
touchAction: 'none'
}; // Unified API for subscribing to events about both
// basic input events (e.g. 'mousemove', 'touchstart', 'wheel')
// and gestural input (e.g. 'click', 'tap', 'panstart').
// Delegates gesture related event registration and handling to Hammer.js.
};
var EventManager =
/*#__PURE__*/
function () {
var EventManager = function () {
function EventManager() {

@@ -61,4 +32,3 @@ var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

this._onOtherEvent = this._onOtherEvent.bind(this);
this.setElement(element); // Register all passed events.
this.setElement(element);
var events = options.events;

@@ -77,3 +47,2 @@

if (this.element) {
// unregister all events
this.destroy();

@@ -96,4 +65,2 @@ }

if (!options.recognizers) {
// Set default recognize withs
// http://hammerjs.github.io/recognize-with/
Object.keys(RECOGNIZER_COMPATIBLE_MAP).forEach(function (name) {

@@ -108,5 +75,4 @@ var recognizer = _this.manager.get(name);

});
} // Set recognizer options
}
for (var recognizerName in options.recognizerOptions) {

@@ -116,12 +82,8 @@ var recognizer = this.manager.get(recognizerName);

if (recognizer) {
var recognizerOption = options.recognizerOptions[recognizerName]; // `enable` is managed by the event registrations
var recognizerOption = options.recognizerOptions[recognizerName];
delete recognizerOption.enable;
recognizer.set(recognizerOption);
}
} // Handle events not handled by Hammer.js:
// - mouse wheel
// - pointer/touch/mouse move
}
this.wheelInput = new WheelInput(element, this._onOtherEvent, {

@@ -138,4 +100,3 @@ enable: false

enable: false
}); // Register all existing events
});
var _iteratorNormalCompletion = true;

@@ -152,3 +113,2 @@ var _didIteratorError = false;

if (!eventRegistrar.isEmpty()) {
// Enable recognizer for this event.
this._toggleRecognizer(eventRegistrar.recognizerName, true);

@@ -164,4 +124,4 @@

try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}

@@ -174,4 +134,3 @@ } finally {

}
} // Tear down internal event management implementations.
}
}, {

@@ -181,4 +140,2 @@ key: "destroy",

if (this.element) {
// wheelInput etc. are created in setElement() and therefore
// cannot exist if there is no element
this.wheelInput.destroy();

@@ -196,39 +153,18 @@ this.moveInput.destroy();

}
} // Register an event handler function to be called on `event`.
}
}, {
key: "on",
value: function on(event, handler, srcElement) {
if (typeof event === 'string') {
this._addEventHandler(event, handler, srcElement);
} else {
srcElement = handler; // If `event` is a map, call `on()` for each entry.
for (var eventName in event) {
this._addEventHandler(eventName, event[eventName], srcElement);
}
}
this._addEventHandler(event, handler, srcElement, false);
}
/**
* Deregister a previously-registered event handler.
* @param {string|Object} event An event name (String) or map of event names to handlers
* @param {Function} [handler] The function to be called on `event`.
*/
}, {
key: "once",
value: function once(event, handler, srcElement) {
this._addEventHandler(event, handler, srcElement, true);
}
}, {
key: "off",
value: function off(event, handler) {
if (typeof event === 'string') {
this._removeEventHandler(event, handler);
} else {
// If `event` is a map, call `off()` for each entry.
for (var eventName in event) {
this._removeEventHandler(eventName, event[eventName]);
}
}
this._removeEventHandler(event, handler);
}
/*
* Enable/disable recognizer for the given event
*/
}, {

@@ -252,4 +188,2 @@ key: "_toggleRecognizer",

if (fallbackRecognizers && !this.options.recognizers) {
// Set default require failures
// http://hammerjs.github.io/require-failure/
fallbackRecognizers.forEach(function (otherName) {

@@ -259,15 +193,5 @@ var otherRecognizer = manager.get(otherName);

if (enabled) {
// Wait for this recognizer to fail
otherRecognizer.requireFailure(name);
/**
* This seems to be a bug in hammerjs:
* requireFailure() adds both ways
* dropRequireFailure() only drops one way
* https://github.com/hammerjs/hammer.js/blob/master/src/recognizerjs/
recognizer-constructor.js#L136
*/
recognizer.dropRequireFailure(otherName);
} else {
// Do not wait for this recognizer to fail
otherRecognizer.dropRequireFailure(name);

@@ -284,12 +208,17 @@ }

}
/**
* Process the event registration for a single event + handler.
*/
}, {
key: "_addEventHandler",
value: function _addEventHandler(event, handler, srcElement) {
value: function _addEventHandler(event, handler, srcElement, once) {
if (typeof event !== 'string') {
srcElement = handler;
for (var eventName in event) {
this._addEventHandler(eventName, event[eventName], srcElement, once);
}
return;
}
var manager = this.manager,
events = this.events; // Alias to a recognized gesture as necessary.
events = this.events;
var eventAlias = GESTURE_EVENT_ALIASES[event] || event;

@@ -300,6 +229,5 @@ var eventRegistrar = events.get(eventAlias);

eventRegistrar = new EventRegistrar(this);
events.set(eventAlias, eventRegistrar); // Enable recognizer for this event.
events.set(eventAlias, eventRegistrar);
eventRegistrar.recognizerName = EVENT_RECOGNIZER_MAP[eventAlias] || eventAlias;
eventRegistrar.recognizerName = EVENT_RECOGNIZER_MAP[eventAlias] || eventAlias; // Listen to the event
if (manager) {

@@ -312,13 +240,16 @@ manager.on(eventAlias, eventRegistrar.handleEvent);

eventRegistrar.add(event, handler, srcElement);
eventRegistrar.add(event, handler, srcElement, once);
}
/**
* Process the event deregistration for a single event + handler.
*/
}, {
key: "_removeEventHandler",
value: function _removeEventHandler(event, handler) {
var events = this.events; // Alias to a recognized gesture as necessary.
if (typeof event !== 'string') {
for (var eventName in event) {
this._removeEventHandler(eventName, event[eventName]);
}
return;
}
var events = this.events;
var eventAlias = GESTURE_EVENT_ALIASES[event] || event;

@@ -334,4 +265,3 @@ var eventRegistrar = events.get(eventAlias);

if (eventRegistrar.isEmpty()) {
var recognizerName = eventRegistrar.recognizerName; // Disable recognizer if no more handlers are attached to its events
var recognizerName = eventRegistrar.recognizerName;
var isRecognizerUsed = false;

@@ -356,4 +286,4 @@ var _iteratorNormalCompletion2 = true;

try {
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
_iterator2.return();
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}

@@ -372,10 +302,2 @@ } finally {

}
/**
* Handle basic events using the 'hammer.input' Hammer.js API:
* Before running Recognizers, Hammer emits a 'hammer.input' event
* with the basic event info. This function emits all basic events
* aliased to the "class" of event received.
* See constants.BASIC_EVENT_CLASSES basic event class definitions.
*/
}, {

@@ -388,15 +310,8 @@ key: "_onBasicInput",

if (alias) {
// fire all events aliased to srcEvent.type
this.manager.emit(alias, event);
}
}
/**
* Handle events not supported by Hammer.js,
* and pipe back out through same (Hammer) channel used by other events.
*/
}, {
key: "_onOtherEvent",
value: function _onOtherEvent(event) {
// console.log('onotherevent', event.type, event)
this.manager.emit(event.type, event);

@@ -409,2 +324,3 @@ }

export { EventManager as default };
export { EventManager as default };
//# sourceMappingURL=event-manager.js.map

@@ -1,20 +0,2 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
export { default as EventManager } from './event-manager';
export { default as EventManager } from './event-manager';
//# sourceMappingURL=index.js.map
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
var EVENT_TYPE = 'contextmenu';
var ContextmenuInput =
/*#__PURE__*/
function () {
var ContextmenuInput = function () {
function ContextmenuInput(element, callback) {

@@ -46,7 +25,2 @@ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

}
/**
* Enable this input (begin processing events)
* if the specified event type is among those handled by this input.
*/
}, {

@@ -82,2 +56,3 @@ key: "enableEventType",

export { ContextmenuInput as default };
export { ContextmenuInput as default };
//# sourceMappingURL=contextmenu-input.js.map
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { INPUT_EVENT_TYPES } from '../constants';

@@ -27,5 +8,3 @@ var KEY_EVENTS = INPUT_EVENT_TYPES.KEY_EVENTS;

var KeyInput =
/*#__PURE__*/
function () {
var KeyInput = function () {
function KeyInput(element, callback) {

@@ -63,7 +42,2 @@ var _this = this;

}
/**
* Enable this input (begin processing events)
* if the specified event type is among those handled by this input.
*/
}, {

@@ -83,3 +57,2 @@ key: "enableEventType",

value: function handleEvent(event) {
// Ignore if focused on text input
var targetElement = event.target || event.srcElement;

@@ -114,2 +87,3 @@

export { KeyInput as default };
export { KeyInput as default };
//# sourceMappingURL=key-input.js.map
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { INPUT_EVENT_TYPES } from '../constants';

@@ -28,14 +9,4 @@ var MOUSE_EVENTS = INPUT_EVENT_TYPES.MOUSE_EVENTS;

var LEAVE_EVENT_TYPE = 'pointerleave';
/**
* Hammer.js swallows 'move' events (for pointer/touch/mouse)
* when the pointer is not down. This class sets up a handler
* specifically for these events to work around this limitation.
* Note that this could be extended to more intelligently handle
* move events across input types, e.g. storing multiple simultaneous
* pointer/touch events, calculating speed/direction, etc.
*/
var MoveInput =
/*#__PURE__*/
function () {
var MoveInput = function () {
function MoveInput(element, callback) {

@@ -74,7 +45,2 @@ var _this = this;

}
/**
* Enable this input (begin processing events)
* if the specified event type is among those handled by this input.
*/
}, {

@@ -156,3 +122,2 @@ key: "enableEventType",

if (event.button >= 0) {
// Button is down
this.pressed = true;

@@ -164,5 +129,3 @@ }

case 'mousemove':
// Move events use `which` to track the button being pressed
if (event.which === 0) {
// Button is not down
this.pressed = false;

@@ -172,4 +135,2 @@ }

if (!this.pressed) {
// Drag events are emitted by hammer already
// we just need to emit the move event on hover
this.callback({

@@ -198,2 +159,3 @@ type: MOVE_EVENT_TYPE,

export { MoveInput as default };
export { MoveInput as default };
//# sourceMappingURL=move-input.js.map
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { INPUT_EVENT_TYPES } from '../constants';

@@ -26,12 +7,8 @@ import { window, userAgent, passiveSupported } from '../utils/globals';

var WHEEL_EVENTS = INPUT_EVENT_TYPES.WHEEL_EVENTS;
var EVENT_TYPE = 'wheel'; // Constants for normalizing input delta
var EVENT_TYPE = 'wheel';
var WHEEL_DELTA_MAGIC_SCALER = 4.000244140625;
var WHEEL_DELTA_PER_LINE = 40; // Slow down zoom if shift key is held for more precise zooming
var WHEEL_DELTA_PER_LINE = 40;
var SHIFT_MULTIPLIER = 0.25;
var WheelInput =
/*#__PURE__*/
function () {
var WheelInput = function () {
function WheelInput(element, callback) {

@@ -67,7 +44,2 @@ var _this = this;

}
/**
* Enable this input (begin processing events)
* if the specified event type is among those handled by this input.
*/
}, {

@@ -80,4 +52,2 @@ key: "enableEventType",

}
/* eslint-disable complexity, max-statements */
}, {

@@ -93,3 +63,2 @@ key: "handleEvent",

if (window.WheelEvent) {
// Firefox doubles the values on retina screens...
if (firefox && event.deltaMode === window.WheelEvent.DOM_DELTA_PIXEL) {

@@ -110,4 +79,2 @@ value /= window.devicePixelRatio;

if (value !== 0 && value % WHEEL_DELTA_MAGIC_SCALER === 0) {
// This one is definitely a mouse wheel event.
// Normalize this value to match trackpad.
value = Math.floor(value / WHEEL_DELTA_MAGIC_SCALER);

@@ -139,2 +106,3 @@ }

export { WheelInput as default };
export { WheelInput as default };
//# sourceMappingURL=wheel-input.js.map

@@ -5,5 +5,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

var EventRegistrar =
/*#__PURE__*/
function () {
var EventRegistrar = function () {
function EventRegistrar(eventManager) {

@@ -13,4 +11,3 @@ _classCallCheck(this, EventRegistrar);

this.eventManager = eventManager;
this.handlers = []; // Element -> handler map
this.handlers = [];
this.handlersByElement = new Map();

@@ -29,2 +26,3 @@ this.handleEvent = this.handleEvent.bind(this);

var srcElement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'root';
var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var handlers = this.handlers,

@@ -40,3 +38,4 @@ handlersByElement = this.handlersByElement;

handler: handler,
srcElement: srcElement
srcElement: srcElement,
once: once
};

@@ -61,3 +60,3 @@ handlers.push(entry);

if (entries.length === 0) {
handlersByElement.delete(entry.srcElement);
handlersByElement["delete"](entry.srcElement);
}

@@ -67,6 +66,2 @@ }

}
/**
* Handles hammerjs event
*/
}, {

@@ -95,6 +90,2 @@ key: "handleEvent",

}
/**
* Invoke handlers on a particular element
*/
}, {

@@ -106,9 +97,8 @@ key: "_emit",

if (entries) {
var immediatePropagationStopped = false; // Prevents the current event from bubbling up
var immediatePropagationStopped = false;
var stopPropagation = function stopPropagation() {
event.handled = true;
}; // Prevent any remaining listeners from being called
};
var stopImmediatePropagation = function stopImmediatePropagation() {

@@ -119,6 +109,9 @@ event.handled = true;

var entriesToRemove = [];
for (var i = 0; i < entries.length; i++) {
var _entries$i = entries[i],
type = _entries$i.type,
handler = _entries$i.handler;
handler = _entries$i.handler,
once = _entries$i.once;
handler(Object.assign({}, event, {

@@ -130,2 +123,6 @@ type: type,

if (once) {
entriesToRemove.push(entries[i]);
}
if (immediatePropagationStopped) {

@@ -135,8 +132,11 @@ break;

}
for (var _i = 0; _i < entriesToRemove.length; _i++) {
var _entriesToRemove$_i = entriesToRemove[_i],
type = _entriesToRemove$_i.type,
handler = _entriesToRemove$_i.handler;
this.remove(type, handler);
}
}
}
/**
* Normalizes hammerjs and custom events to have predictable fields.
*/
}, {

@@ -156,2 +156,3 @@ key: "_normalizeEvent",

export { EventRegistrar as default };
export { EventRegistrar as default };
//# sourceMappingURL=event-registrar.js.map

@@ -1,2 +0,1 @@

/* Constants */
var DOWN_EVENT = 1;

@@ -12,19 +11,12 @@ var MOVE_EVENT = 2;

mouseup: UP_EVENT
}; // MouseEvent.which https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
};
var MOUSE_EVENT_WHICH_LEFT = 1;
var MOUSE_EVENT_WHICH_MIDDLE = 2;
var MOUSE_EVENT_WHICH_RIGHT = 3; // MouseEvent.button https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
var MOUSE_EVENT_WHICH_RIGHT = 3;
var MOUSE_EVENT_BUTTON_LEFT = 0;
var MOUSE_EVENT_BUTTON_MIDDLE = 1;
var MOUSE_EVENT_BUTTON_RIGHT = 2; // MouseEvent.buttons https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
var MOUSE_EVENT_BUTTON_RIGHT = 2;
var MOUSE_EVENT_BUTTONS_LEFT_MASK = 1;
var MOUSE_EVENT_BUTTONS_RIGHT_MASK = 2;
var MOUSE_EVENT_BUTTONS_MIDDLE_MASK = 4;
/**
* Extract the involved mouse button
*/
export function whichButtons(event) {

@@ -34,3 +26,2 @@ var eventType = MOUSE_EVENTS[event.srcEvent.type];

if (!eventType) {
// Not a mouse evet
return null;

@@ -47,5 +38,3 @@ }

if ( // button is up, need to find out which one was pressed before
eventType === UP_EVENT || // moving but does not support `buttons` API
eventType === MOVE_EVENT && !Number.isFinite(buttons)) {
if (eventType === UP_EVENT || eventType === MOVE_EVENT && !Number.isFinite(buttons)) {
leftButton = which === MOUSE_EVENT_WHICH_LEFT;

@@ -70,11 +59,6 @@ middleButton = which === MOUSE_EVENT_WHICH_MIDDLE;

}
/**
* Calculate event position relative to the root element
*/
export function getOffsetPosition(event, rootElement) {
var srcEvent = event.srcEvent; // `center` is a hammer.js event property
var srcEvent = event.srcEvent;
if (!event.center && !Number.isFinite(srcEvent.clientX)) {
// Not a gestural event
return null;

@@ -87,8 +71,5 @@ }

};
var rect = rootElement.getBoundingClientRect(); // Fix scale for map affected by a CSS transform.
// See https://stackoverflow.com/a/26893663/3528533
var rect = rootElement.getBoundingClientRect();
var scaleX = rect.width / rootElement.offsetWidth;
var scaleY = rect.height / rootElement.offsetHeight; // Calculate center relative to the root element
var scaleY = rect.height / rootElement.offsetHeight;
var offsetCenter = {

@@ -102,2 +83,3 @@ x: (center.x - rect.left - rootElement.clientLeft) / scaleX,

};
}
}
//# sourceMappingURL=event-utils.js.map

@@ -1,43 +0,1 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// Purpose: include this in your module to avoids adding dependencies on
// micro modules like 'global'
/* global window, global, document, navigator */
export var userAgent = typeof navigator !== 'undefined' && navigator.userAgent ? navigator.userAgent.toLowerCase() : '';

@@ -48,17 +6,9 @@ var window_ = typeof window !== 'undefined' ? window : global;

export { window_ as window, global_ as global, document_ as document };
/*
* Detect whether passive option is supported by the current browser.
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
#Safely_detecting_option_support
*/
var passiveSupported = false;
/* eslint-disable accessor-pairs, no-empty */
try {
var options = {
// This function will be called when the browser
// attempts to access the passive property.
get passive() {
passiveSupported = true;
return true;
}

@@ -71,2 +21,3 @@

export { passiveSupported };
export { passiveSupported };
//# sourceMappingURL=globals.js.map

@@ -1,2 +0,1 @@

// Hammer.Manager mock for use in environments without `document` / `window`.
export default function HammerManagerMock(m) {

@@ -19,2 +18,3 @@ var instance = {};

return instance;
}
}
//# sourceMappingURL=hammer-manager-mock.js.map

@@ -1,7 +0,1 @@

/**
* This file contains overrides the default
* hammer.js functions to add our own utility
*/
/* Hammer.js constants */
var INPUT_START = 1;

@@ -15,8 +9,2 @@ var INPUT_MOVE = 2;

};
/**
* Helper function that returns true if any element in an array meets given criteria.
* Because older browsers do not support `Array.prototype.some`
* @params array {Array}
* @params predict {Function}
*/

@@ -32,10 +20,8 @@ function some(array, predict) {

}
/* eslint-disable no-invalid-this */
export function enhancePointerEventInput(PointerEventInput) {
var oldHandler = PointerEventInput.prototype.handler; // overrides PointerEventInput.handler to accept right mouse button
var oldHandler = PointerEventInput.prototype.handler;
PointerEventInput.prototype.handler = function handler(ev) {
var store = this.store; // Allow non-left mouse buttons through
var store = this.store;

@@ -52,7 +38,6 @@ if (ev.button > 0) {

};
} // overrides MouseInput.handler to accept right mouse button
}
export function enhanceMouseInput(MouseInput) {
MouseInput.prototype.handler = function handler(ev) {
var eventType = MOUSE_INPUT_MAP[ev.type]; // on start we want to have the mouse button down
var eventType = MOUSE_INPUT_MAP[ev.type];

@@ -65,5 +50,4 @@ if (eventType & INPUT_START && ev.button >= 0) {

eventType = INPUT_END;
} // mouse must be down
}
if (!this.pressed) {

@@ -84,2 +68,3 @@ return;

};
}
}
//# sourceMappingURL=hammer-overrides.js.map

@@ -1,20 +0,1 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import { enhancePointerEventInput, enhanceMouseInput } from './hammer-overrides';

@@ -24,3 +5,2 @@ var hammerjs = null;

if (typeof document !== 'undefined') {
// Avoid crash if imported in a web worker
hammerjs = require('hammerjs');

@@ -31,2 +11,3 @@ enhancePointerEventInput(hammerjs.PointerEventInput);

export default hammerjs;
export default hammerjs;
//# sourceMappingURL=hammer.browser.js.map

@@ -1,22 +0,2 @@

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// This is replaced with hammer.browser.js when bundled in a browser environment
// See `browser` field in package.json
export default null;
export default null;
//# sourceMappingURL=hammer.js.map
{
"name": "mjolnir.js",
"description": "An Event Manager",
"version": "2.1.2",
"version": "2.2.0-beta.1",
"keywords": [

@@ -18,6 +18,9 @@ "hammerjs",

"license": "MIT",
"main": "dist/cjs/index.js",
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",
"esnext": "dist/es6/index.js",
"browser": {
"./dist/cjs/utils/hammer.js": "./dist/cjs/utils/hammer.browser.js",
"./src/utils/hammer.js": "./src/utils/hammer.browser.js",
"./dist/es5/utils/hammer.js": "./dist/es5/utils/hammer.browser.js",
"./dist/es6/utils/hammer.js": "./dist/es6/utils/hammer.browser.js",
"./dist/esm/utils/hammer.js": "./dist/esm/utils/hammer.browser.js"

@@ -30,11 +33,12 @@ },

"scripts": {
"bootstrap": "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true yarn && ocular-bootstrap",
"start": "(cd examples/main && (path-exists node_modules || npm i) && npm run start-local)",
"build": "npm run clean && npm run build-cjs && npm run build-esm",
"build-cjs": "mkdir -p dist/cjs && NODE_ENV=cjs babel src --out-dir dist/cjs",
"build-esm": "mkdir -p dist/esm && NODE_ENV=esm babel src --out-dir dist/esm",
"clean": "rm -fr dist/*",
"lint": "eslint src examples test",
"test": "npm run lint && node test/node.js",
"publish-prod": "npm run build && npm run test && npm publish",
"publish-beta": "npm run build && npm run test && npm publish --tag beta"
"build": "ocular-clean && ocular-build",
"lint": "ocular-lint",
"cover:node": "nyc --silent ocular-test node",
"cover:browser": "MOCK_BROWSER=true nyc --silent --no-clean ocular-test node",
"cover": "npm run cover:node && npm run cover:browser && nyc report --reporter=lcov",
"publish-prod": "ocular-publish prod",
"publish-beta": "ocular-publish beta",
"test": "ocular-test"
},

@@ -49,19 +53,9 @@ "pre-commit": [

"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.5",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.5",
"babel-eslint": "^9.0.0",
"eslint": "^5.5.0",
"eslint-config-uber-es2015": "^3.0.0",
"eslint-config-uber-jsx": "^3.0.0",
"eslint-plugin-react": "~7.11.1",
"module-alias": "^2.0.0",
"coveralls": "^3.0.0",
"ocular-dev-tools": "0.0.27",
"jsdom": "^15.0.0",
"pre-commit": "^1.2.2",
"reify": "^0.4.4",
"tap-browser-color": "^0.1.2",
"tape": "^4.5.1",
"tape-catch": "^1.0.4",
"webpack": "^2.4.0",
"webpack-dev-server": "^3.1.11"
"reify": "^0.18.1"
},

@@ -68,0 +62,0 @@ "engines": {

@@ -25,13 +25,15 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// due to `window`/`document` references downstream.
export const RECOGNIZERS = Hammer ? [
[Hammer.Rotate, {enable: false}],
[Hammer.Pinch, {enable: false}],
[Hammer.Swipe, {enable: false}],
[Hammer.Pan, {threshold: 0, enable: false}],
[Hammer.Press, {enable: false}],
[Hammer.Tap, {event: 'doubletap', taps: 2, enable: false}],
// TODO - rename to 'tap' and 'singletap' in the next major release
[Hammer.Tap, {event: 'anytap', enable: false}],
[Hammer.Tap, {enable: false}]
] : null;
export const RECOGNIZERS = Hammer
? [
[Hammer.Rotate, {enable: false}],
[Hammer.Pinch, {enable: false}],
[Hammer.Swipe, {enable: false}],
[Hammer.Pan, {threshold: 0, enable: false}],
[Hammer.Press, {enable: false}],
[Hammer.Tap, {event: 'doubletap', taps: 2, enable: false}],
// TODO - rename to 'tap' and 'singletap' in the next major release
[Hammer.Tap, {event: 'anytap', enable: false}],
[Hammer.Tap, {enable: false}]
]
: null;

@@ -71,14 +73,4 @@ // Recognize the following gestures even if a given recognizer succeeds

export const INPUT_EVENT_TYPES = {
KEY_EVENTS: [
'keydown',
'keyup'
],
MOUSE_EVENTS: [
'mousedown',
'mousemove',
'mouseup',
'mouseover',
'mouseout',
'mouseleave'
],
KEY_EVENTS: ['keydown', 'keyup'],
MOUSE_EVENTS: ['mousedown', 'mousemove', 'mouseup', 'mouseover', 'mouseout', 'mouseleave'],
WHEEL_EVENTS: [

@@ -85,0 +77,0 @@ // Chrome, Safari

@@ -90,4 +90,3 @@ // Copyright (c) 2017 Uber Technologies, Inc.

recognizers: options.recognizers || RECOGNIZERS
})
.on('hammer.input', this._onBasicInput);
}).on('hammer.input', this._onBasicInput);

@@ -121,6 +120,14 @@ if (!options.recognizers) {

// - pointer/touch/mouse move
this.wheelInput = new WheelInput(element, this._onOtherEvent, {enable: false});
this.moveInput = new MoveInput(element, this._onOtherEvent, {enable: false});
this.keyInput = new KeyInput(element, this._onOtherEvent, {enable: false});
this.contextmenuInput = new ContextmenuInput(element, this._onOtherEvent, {enable: false});
this.wheelInput = new WheelInput(element, this._onOtherEvent, {
enable: false
});
this.moveInput = new MoveInput(element, this._onOtherEvent, {
enable: false
});
this.keyInput = new KeyInput(element, this._onOtherEvent, {
enable: false
});
this.contextmenuInput = new ContextmenuInput(element, this._onOtherEvent, {
enable: false
});

@@ -159,13 +166,10 @@ // Register all existing events

on(event, handler, srcElement) {
if (typeof event === 'string') {
this._addEventHandler(event, handler, srcElement);
} else {
srcElement = handler;
// If `event` is a map, call `on()` for each entry.
for (const eventName in event) {
this._addEventHandler(eventName, event[eventName], srcElement);
}
}
this._addEventHandler(event, handler, srcElement, false);
}
// Register an event handler function to be called on `event`, then remove it
once(event, handler, srcElement) {
this._addEventHandler(event, handler, srcElement, true);
}
/**

@@ -177,10 +181,3 @@ * Deregister a previously-registered event handler.

off(event, handler) {
if (typeof event === 'string') {
this._removeEventHandler(event, handler);
} else {
// If `event` is a map, call `off()` for each entry.
for (const eventName in event) {
this._removeEventHandler(eventName, event[eventName]);
}
}
this._removeEventHandler(event, handler);
}

@@ -233,3 +230,12 @@

*/
_addEventHandler(event, handler, srcElement) {
_addEventHandler(event, handler, srcElement, once) {
if (typeof event !== 'string') {
srcElement = handler;
// If `event` is a map, call `on()` for each entry.
for (const eventName in event) {
this._addEventHandler(eventName, event[eventName], srcElement, once);
}
return;
}
const {manager, events} = this;

@@ -251,3 +257,3 @@ // Alias to a recognized gesture as necessary.

this._toggleRecognizer(eventRegistrar.recognizerName, true);
eventRegistrar.add(event, handler, srcElement);
eventRegistrar.add(event, handler, srcElement, once);
}

@@ -259,2 +265,10 @@

_removeEventHandler(event, handler) {
if (typeof event !== 'string') {
// If `event` is a map, call `off()` for each entry.
for (const eventName in event) {
this._removeEventHandler(eventName, event[eventName]);
}
return;
}
const {events} = this;

@@ -261,0 +275,0 @@ // Alias to a recognized gesture as necessary.

@@ -24,3 +24,2 @@ // Copyright (c) 2017 Uber Technologies, Inc.

export default class ContextmenuInput {
constructor(element, callback, options = {}) {

@@ -27,0 +26,0 @@ this.element = element;

@@ -65,4 +65,6 @@ // Copyright (c) 2017 Uber Technologies, Inc.

const targetElement = event.target || event.srcElement;
if ((targetElement.tagName === 'INPUT' && targetElement.type === 'text') ||
targetElement.tagName === 'TEXTAREA') {
if (
(targetElement.tagName === 'INPUT' && targetElement.type === 'text') ||
targetElement.tagName === 'TEXTAREA'
) {
return;

@@ -69,0 +71,0 @@ }

@@ -38,3 +38,2 @@ // Copyright (c) 2017 Uber Technologies, Inc.

export default class MoveInput {
constructor(element, callback, options = {}) {

@@ -129,29 +128,29 @@ this.element = element;

switch (event.type) {
case 'mousedown':
if (event.button >= 0) {
// Button is down
this.pressed = true;
}
break;
case 'mousemove':
// Move events use `which` to track the button being pressed
if (event.which === 0) {
// Button is not down
case 'mousedown':
if (event.button >= 0) {
// Button is down
this.pressed = true;
}
break;
case 'mousemove':
// Move events use `which` to track the button being pressed
if (event.which === 0) {
// Button is not down
this.pressed = false;
}
if (!this.pressed) {
// Drag events are emitted by hammer already
// we just need to emit the move event on hover
this.callback({
type: MOVE_EVENT_TYPE,
srcEvent: event,
pointerType: 'mouse',
target: event.target
});
}
break;
case 'mouseup':
this.pressed = false;
}
if (!this.pressed) {
// Drag events are emitted by hammer already
// we just need to emit the move event on hover
this.callback({
type: MOVE_EVENT_TYPE,
srcEvent: event,
pointerType: 'mouse',
target: event.target
});
}
break;
case 'mouseup':
this.pressed = false;
break;
default:
break;
default:
}

@@ -158,0 +157,0 @@ }

@@ -36,3 +36,2 @@ // Copyright (c) 2017 Uber Technologies, Inc.

export default class WheelInput {
constructor(element, callback, options = {}) {

@@ -47,7 +46,5 @@ this.element = element;

this.handleEvent = this.handleEvent.bind(this);
this.events.forEach(event => element.addEventListener(
event,
this.handleEvent,
passiveSupported ? {passive: false} : false
));
this.events.forEach(event =>
element.addEventListener(event, this.handleEvent, passiveSupported ? {passive: false} : false)
);
}

@@ -54,0 +51,0 @@

@@ -17,3 +17,3 @@ import {whichButtons, getOffsetPosition} from './event-utils';

add(type, handler, srcElement = 'root') {
add(type, handler, srcElement = 'root', once = false) {
const {handlers, handlersByElement} = this;

@@ -24,3 +24,3 @@

}
const entry = {type, handler, srcElement};
const entry = {type, handler, srcElement, once};
handlers.push(entry);

@@ -86,9 +86,16 @@ handlersByElement.get(srcElement).push(entry);

};
const entriesToRemove = [];
for (let i = 0; i < entries.length; i++) {
const {type, handler} = entries[i];
handler(Object.assign({}, event, {
type,
stopPropagation,
stopImmediatePropagation
}));
const {type, handler, once} = entries[i];
handler(
Object.assign({}, event, {
type,
stopPropagation,
stopImmediatePropagation
})
);
if (once) {
entriesToRemove.push(entries[i]);
}
if (immediatePropagationStopped) {

@@ -98,2 +105,7 @@ break;

}
for (let i = 0; i < entriesToRemove.length; i++) {
const {type, handler} = entriesToRemove[i];
this.remove(type, handler);
}
}

@@ -108,11 +120,7 @@ }

return Object.assign({}, event,
whichButtons(event),
getOffsetPosition(event, rootElement),
{
handled: false,
rootElement
});
return Object.assign({}, event, whichButtons(event), getOffsetPosition(event, rootElement), {
handled: false,
rootElement
});
}
}

@@ -21,22 +21,2 @@ // Copyright (c) 2017 Uber Technologies, Inc.

// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// Purpose: include this in your module to avoids adding dependencies on

@@ -46,4 +26,4 @@ // micro modules like 'global'

/* global window, global, document, navigator */
export const userAgent = (typeof navigator !== 'undefined' && navigator.userAgent) ?
navigator.userAgent.toLowerCase() : '';
export const userAgent =
typeof navigator !== 'undefined' && navigator.userAgent ? navigator.userAgent.toLowerCase() : '';

@@ -54,7 +34,3 @@ const window_ = typeof window !== 'undefined' ? window : global;

export {
window_ as window,
global_ as global,
document_ as document
};
export {window_ as window, global_ as global, document_ as document};

@@ -75,2 +51,3 @@ /*

passiveSupported = true;
return true;
}

@@ -77,0 +54,0 @@ };