Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-dnd-touch-backend

Package Overview
Dependencies
Maintainers
3
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dnd-touch-backend - npm Package Compare versions

Comparing version 9.4.0 to 9.5.0

rollup.config.js

902

dist/umd/ReactDnDTouchBackend.js

@@ -1,208 +0,750 @@

(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["ReactDnDTouchBackend"] = factory();
else
root["ReactDnDTouchBackend"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./lib/index.js");
/******/ })
/************************************************************************/
/******/ ({
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.ReactDnDTouchBackend = factory());
}(this, (function () { 'use strict';
/***/ "../../../node_modules/invariant/browser.js":
/*!*************************************************************************************!*\
!*** /Users/christrevino/Workspace/oss/react-dnd/node_modules/invariant/browser.js ***!
\*************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
"use strict";
eval("/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n\n/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nvar invariant = function(condition, format, a, b, c, d, e, f) {\n if (true) {\n if (format === undefined) {\n throw new Error('invariant requires an error message argument');\n }\n }\n\n if (!condition) {\n var error;\n if (format === undefined) {\n error = new Error(\n 'Minified exception occurred; use the non-minified dev environment ' +\n 'for the full error message and additional helpful warnings.'\n );\n } else {\n var args = [a, b, c, d, e, f];\n var argIndex = 0;\n error = new Error(\n format.replace(/%s/g, function() { return args[argIndex++]; })\n );\n error.name = 'Invariant Violation';\n }\n\n error.framesToPop = 1; // we don't care about invariant's own frame\n throw error;\n }\n};\n\nmodule.exports = invariant;\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend//Users/christrevino/Workspace/oss/react-dnd/node_modules/invariant/browser.js?");
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
/***/ }),
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
/***/ "./lib/OptionsReader.js":
/*!******************************!*\
!*** ./lib/OptionsReader.js ***!
\******************************/
/*! exports provided: OptionsReader */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"OptionsReader\", function() { return OptionsReader; });\nclass OptionsReader {\n constructor(incoming, context) {\n this.enableTouchEvents = true;\n this.enableMouseEvents = false;\n this.enableKeyboardEvents = false;\n this.ignoreContextMenu = false;\n this.enableHoverOutsideTarget = false;\n this.touchSlop = 0;\n this.scrollAngleRanges = undefined;\n this.context = context;\n this.delayTouchStart = incoming.delayTouchStart || incoming.delay || 0;\n this.delayMouseStart = incoming.delayMouseStart || incoming.delay || 0;\n Object.keys(incoming).forEach(key => {\n if (incoming[key] != null) {\n ;\n this[key] = incoming[key];\n }\n });\n }\n get window() {\n if (this.context && this.context.window) {\n return this.context.window;\n }\n else if (typeof window !== 'undefined') {\n return window;\n }\n return undefined;\n }\n get document() {\n if (this.window) {\n return this.window.document;\n }\n return undefined;\n }\n}\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/OptionsReader.js?");
return obj;
}
/***/ }),
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
/***/ "./lib/TouchBackend.js":
/*!*****************************!*\
!*** ./lib/TouchBackend.js ***!
\*****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
var NODE_ENV = "development";
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return TouchBackend; });\n/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! invariant */ \"../../../node_modules/invariant/browser.js\");\n/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(invariant__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _interfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./interfaces */ \"./lib/interfaces.js\");\n/* harmony import */ var _utils_predicates__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils/predicates */ \"./lib/utils/predicates.js\");\n/* harmony import */ var _utils_offsets__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils/offsets */ \"./lib/utils/offsets.js\");\n/* harmony import */ var _utils_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils/math */ \"./lib/utils/math.js\");\n/* harmony import */ var _utils_supportsPassive__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils/supportsPassive */ \"./lib/utils/supportsPassive.js\");\n/* harmony import */ var _OptionsReader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./OptionsReader */ \"./lib/OptionsReader.js\");\n\n\n\n\n\n\n\nconst eventNames = {\n [_interfaces__WEBPACK_IMPORTED_MODULE_1__[\"ListenerType\"].mouse]: {\n start: 'mousedown',\n move: 'mousemove',\n end: 'mouseup',\n contextmenu: 'contextmenu',\n },\n [_interfaces__WEBPACK_IMPORTED_MODULE_1__[\"ListenerType\"].touch]: {\n start: 'touchstart',\n move: 'touchmove',\n end: 'touchend',\n },\n [_interfaces__WEBPACK_IMPORTED_MODULE_1__[\"ListenerType\"].keyboard]: {\n keydown: 'keydown',\n },\n};\nclass TouchBackend {\n constructor(manager, context, options) {\n this.getSourceClientOffset = (sourceId) => {\n return Object(_utils_offsets__WEBPACK_IMPORTED_MODULE_3__[\"getNodeClientOffset\"])(this.sourceNodes[sourceId]);\n };\n this.handleTopMoveStartCapture = (e) => {\n if (!Object(_utils_predicates__WEBPACK_IMPORTED_MODULE_2__[\"eventShouldStartDrag\"])(e)) {\n return;\n }\n this.moveStartSourceIds = [];\n };\n this.handleMoveStart = (sourceId) => {\n // Just because we received an event doesn't necessarily mean we need to collect drag sources.\n // We only collect start collecting drag sources on touch and left mouse events.\n if (Array.isArray(this.moveStartSourceIds)) {\n this.moveStartSourceIds.unshift(sourceId);\n }\n };\n this.handleTopMoveStart = (e) => {\n if (!Object(_utils_predicates__WEBPACK_IMPORTED_MODULE_2__[\"eventShouldStartDrag\"])(e)) {\n return;\n }\n // Don't prematurely preventDefault() here since it might:\n // 1. Mess up scrolling\n // 2. Mess up long tap (which brings up context menu)\n // 3. If there's an anchor link as a child, tap won't be triggered on link\n const clientOffset = Object(_utils_offsets__WEBPACK_IMPORTED_MODULE_3__[\"getEventClientOffset\"])(e);\n if (clientOffset) {\n this._mouseClientOffset = clientOffset;\n }\n this.waitingForDelay = false;\n };\n this.handleTopMoveStartDelay = (e) => {\n if (!Object(_utils_predicates__WEBPACK_IMPORTED_MODULE_2__[\"eventShouldStartDrag\"])(e)) {\n return;\n }\n const delay = e.type === eventNames.touch.start\n ? this.options.delayTouchStart\n : this.options.delayMouseStart;\n this.timeout = setTimeout(this.handleTopMoveStart.bind(this, e), delay);\n this.waitingForDelay = true;\n };\n this.handleTopMoveCapture = () => {\n this.dragOverTargetIds = [];\n };\n this.handleMove = (_, targetId) => {\n if (this.dragOverTargetIds) {\n this.dragOverTargetIds.unshift(targetId);\n }\n };\n this.handleTopMove = (e) => {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n if (!this.document || this.waitingForDelay) {\n return;\n }\n const { moveStartSourceIds, dragOverTargetIds } = this;\n const enableHoverOutsideTarget = this.options.enableHoverOutsideTarget;\n const clientOffset = Object(_utils_offsets__WEBPACK_IMPORTED_MODULE_3__[\"getEventClientOffset\"])(e);\n if (!clientOffset) {\n return;\n }\n // If the touch move started as a scroll, or is is between the scroll angles\n if (this._isScrolling ||\n (!this.monitor.isDragging() &&\n Object(_utils_math__WEBPACK_IMPORTED_MODULE_4__[\"inAngleRanges\"])(this._mouseClientOffset.x || 0, this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y, this.options.scrollAngleRanges))) {\n this._isScrolling = true;\n return;\n }\n // If we're not dragging and we've moved a little, that counts as a drag start\n if (!this.monitor.isDragging() &&\n // eslint-disable-next-line no-prototype-builtins\n this._mouseClientOffset.hasOwnProperty('x') &&\n moveStartSourceIds &&\n Object(_utils_math__WEBPACK_IMPORTED_MODULE_4__[\"distance\"])(this._mouseClientOffset.x || 0, this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y) > (this.options.touchSlop ? this.options.touchSlop : 0)) {\n this.moveStartSourceIds = undefined;\n this.actions.beginDrag(moveStartSourceIds, {\n clientOffset: this._mouseClientOffset,\n getSourceClientOffset: this.getSourceClientOffset,\n publishSource: false,\n });\n }\n if (!this.monitor.isDragging()) {\n return;\n }\n const sourceNode = this.sourceNodes[this.monitor.getSourceId()];\n this.installSourceNodeRemovalObserver(sourceNode);\n this.actions.publishDragSource();\n e.preventDefault();\n // Get the node elements of the hovered DropTargets\n const dragOverTargetNodes = (dragOverTargetIds || []).map(key => this.targetNodes[key]);\n // Get the a ordered list of nodes that are touched by\n const elementsAtPoint = this.options.getDropTargetElementsAtPoint\n ? this.options.getDropTargetElementsAtPoint(clientOffset.x, clientOffset.y, dragOverTargetNodes)\n : this.document.elementsFromPoint(clientOffset.x, clientOffset.y);\n // Extend list with parents that are not receiving elementsFromPoint events (size 0 elements and svg groups)\n const elementsAtPointExtended = [];\n for (const nodeId in elementsAtPoint) {\n // eslint-disable-next-line no-prototype-builtins\n if (!elementsAtPoint.hasOwnProperty(nodeId)) {\n continue;\n }\n let currentNode = elementsAtPoint[nodeId];\n elementsAtPointExtended.push(currentNode);\n while (currentNode) {\n currentNode = currentNode.parentElement;\n if (elementsAtPointExtended.indexOf(currentNode) === -1) {\n elementsAtPointExtended.push(currentNode);\n }\n }\n }\n const orderedDragOverTargetIds = elementsAtPointExtended\n // Filter off nodes that arent a hovered DropTargets nodes\n .filter(node => dragOverTargetNodes.indexOf(node) > -1)\n // Map back the nodes elements to targetIds\n .map(node => {\n for (const targetId in this.targetNodes) {\n if (node === this.targetNodes[targetId]) {\n return targetId;\n }\n }\n return undefined;\n })\n // Filter off possible null rows\n .filter(node => !!node)\n .filter((id, index, ids) => ids.indexOf(id) === index);\n // Invoke hover for drop targets when source node is still over and pointer is outside\n if (enableHoverOutsideTarget) {\n for (const targetId in this.targetNodes) {\n if (this.targetNodes[targetId] &&\n this.targetNodes[targetId].contains(sourceNode) &&\n orderedDragOverTargetIds.indexOf(targetId) === -1) {\n orderedDragOverTargetIds.unshift(targetId);\n break;\n }\n }\n }\n // Reverse order because dnd-core reverse it before calling the DropTarget drop methods\n orderedDragOverTargetIds.reverse();\n this.actions.hover(orderedDragOverTargetIds, {\n clientOffset: clientOffset,\n });\n };\n this.handleTopMoveEndCapture = (e) => {\n this._isScrolling = false;\n if (!Object(_utils_predicates__WEBPACK_IMPORTED_MODULE_2__[\"eventShouldEndDrag\"])(e)) {\n return;\n }\n if (!this.monitor.isDragging() || this.monitor.didDrop()) {\n this.moveStartSourceIds = undefined;\n return;\n }\n e.preventDefault();\n this._mouseClientOffset = {};\n this.uninstallSourceNodeRemovalObserver();\n this.actions.drop();\n this.actions.endDrag();\n };\n this.handleCancelOnEscape = (e) => {\n if (e.key === 'Escape' && this.monitor.isDragging()) {\n this._mouseClientOffset = {};\n this.uninstallSourceNodeRemovalObserver();\n this.actions.endDrag();\n }\n };\n this.options = new _OptionsReader__WEBPACK_IMPORTED_MODULE_6__[\"OptionsReader\"](options, context);\n this.actions = manager.getActions();\n this.monitor = manager.getMonitor();\n this.sourceNodes = {};\n this.sourcePreviewNodes = {};\n this.sourcePreviewNodeOptions = {};\n this.targetNodes = {};\n this.listenerTypes = [];\n this._mouseClientOffset = {};\n this._isScrolling = false;\n if (this.options.enableMouseEvents) {\n this.listenerTypes.push(_interfaces__WEBPACK_IMPORTED_MODULE_1__[\"ListenerType\"].mouse);\n }\n if (this.options.enableTouchEvents) {\n this.listenerTypes.push(_interfaces__WEBPACK_IMPORTED_MODULE_1__[\"ListenerType\"].touch);\n }\n if (this.options.enableKeyboardEvents) {\n this.listenerTypes.push(_interfaces__WEBPACK_IMPORTED_MODULE_1__[\"ListenerType\"].keyboard);\n }\n }\n // public for test\n get window() {\n return this.options.window;\n }\n // public for test\n get document() {\n if (this.window) {\n return this.window.document;\n }\n return undefined;\n }\n setup() {\n if (!this.window) {\n return;\n }\n invariant__WEBPACK_IMPORTED_MODULE_0___default()(!TouchBackend.isSetUp, 'Cannot have two Touch backends at the same time.');\n TouchBackend.isSetUp = true;\n this.addEventListener(this.window, 'start', this.getTopMoveStartHandler());\n this.addEventListener(this.window, 'start', this.handleTopMoveStartCapture, true);\n this.addEventListener(this.window, 'move', this.handleTopMove);\n this.addEventListener(this.window, 'move', this.handleTopMoveCapture, true);\n this.addEventListener(this.window, 'end', this.handleTopMoveEndCapture, true);\n if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {\n this.addEventListener(this.window, 'contextmenu', this\n .handleTopMoveEndCapture);\n }\n if (this.options.enableKeyboardEvents) {\n this.addEventListener(this.window, 'keydown', this.handleCancelOnEscape, true);\n }\n }\n teardown() {\n if (!this.window) {\n return;\n }\n TouchBackend.isSetUp = false;\n this._mouseClientOffset = {};\n this.removeEventListener(this.window, 'start', this.handleTopMoveStartCapture, true);\n this.removeEventListener(this.window, 'start', this\n .handleTopMoveStart);\n this.removeEventListener(this.window, 'move', this.handleTopMoveCapture, true);\n this.removeEventListener(this.window, 'move', this.handleTopMove);\n this.removeEventListener(this.window, 'end', this.handleTopMoveEndCapture, true);\n if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {\n this.removeEventListener(this.window, 'contextmenu', this\n .handleTopMoveEndCapture);\n }\n if (this.options.enableKeyboardEvents) {\n this.removeEventListener(this.window, 'keydown', this.handleCancelOnEscape, true);\n }\n this.uninstallSourceNodeRemovalObserver();\n }\n addEventListener(subject, event, handler, capture) {\n const options = _utils_supportsPassive__WEBPACK_IMPORTED_MODULE_5__[\"default\"] ? { capture, passive: false } : capture;\n this.listenerTypes.forEach(function (listenerType) {\n const evt = eventNames[listenerType][event];\n if (evt) {\n subject.addEventListener(evt, handler, options);\n }\n });\n }\n removeEventListener(subject, event, handler, capture) {\n const options = _utils_supportsPassive__WEBPACK_IMPORTED_MODULE_5__[\"default\"] ? { capture, passive: false } : capture;\n this.listenerTypes.forEach(function (listenerType) {\n const evt = eventNames[listenerType][event];\n if (evt) {\n subject.removeEventListener(evt, handler, options);\n }\n });\n }\n connectDragSource(sourceId, node) {\n const handleMoveStart = this.handleMoveStart.bind(this, sourceId);\n this.sourceNodes[sourceId] = node;\n this.addEventListener(node, 'start', handleMoveStart);\n return () => {\n delete this.sourceNodes[sourceId];\n this.removeEventListener(node, 'start', handleMoveStart);\n };\n }\n connectDragPreview(sourceId, node, options) {\n this.sourcePreviewNodeOptions[sourceId] = options;\n this.sourcePreviewNodes[sourceId] = node;\n return () => {\n delete this.sourcePreviewNodes[sourceId];\n delete this.sourcePreviewNodeOptions[sourceId];\n };\n }\n connectDropTarget(targetId, node) {\n if (!this.document) {\n return () => null;\n }\n const handleMove = (e) => {\n if (!this.document || !this.monitor.isDragging()) {\n return;\n }\n let coords;\n /**\n * Grab the coordinates for the current mouse/touch position\n */\n switch (e.type) {\n case eventNames.mouse.move:\n coords = {\n x: e.clientX,\n y: e.clientY,\n };\n break;\n case eventNames.touch.move:\n coords = {\n x: e.touches[0].clientX,\n y: e.touches[0].clientY,\n };\n break;\n }\n /**\n * Use the coordinates to grab the element the drag ended on.\n * If the element is the same as the target node (or any of it's children) then we have hit a drop target and can handle the move.\n */\n const droppedOn = coords != null\n ? this.document.elementFromPoint(coords.x, coords.y)\n : undefined;\n const childMatch = droppedOn && node.contains(droppedOn);\n if (droppedOn === node || childMatch) {\n return this.handleMove(e, targetId);\n }\n };\n /**\n * Attaching the event listener to the body so that touchmove will work while dragging over multiple target elements.\n */\n this.addEventListener(this.document.body, 'move', handleMove);\n this.targetNodes[targetId] = node;\n return () => {\n if (this.document) {\n delete this.targetNodes[targetId];\n this.removeEventListener(this.document.body, 'move', handleMove);\n }\n };\n }\n getTopMoveStartHandler() {\n if (!this.options.delayTouchStart && !this.options.delayMouseStart) {\n return this.handleTopMoveStart;\n }\n return this.handleTopMoveStartDelay;\n }\n installSourceNodeRemovalObserver(node) {\n this.uninstallSourceNodeRemovalObserver();\n this.draggedSourceNode = node;\n this.draggedSourceNodeRemovalObserver = new MutationObserver(() => {\n if (node && !node.parentElement) {\n this.resurrectSourceNode();\n this.uninstallSourceNodeRemovalObserver();\n }\n });\n if (!node || !node.parentElement) {\n return;\n }\n this.draggedSourceNodeRemovalObserver.observe(node.parentElement, {\n childList: true,\n });\n }\n resurrectSourceNode() {\n if (this.document && this.draggedSourceNode) {\n this.draggedSourceNode.style.display = 'none';\n this.draggedSourceNode.removeAttribute('data-reactid');\n this.document.body.appendChild(this.draggedSourceNode);\n }\n }\n uninstallSourceNodeRemovalObserver() {\n if (this.draggedSourceNodeRemovalObserver) {\n this.draggedSourceNodeRemovalObserver.disconnect();\n }\n this.draggedSourceNodeRemovalObserver = undefined;\n this.draggedSourceNode = undefined;\n }\n}\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/TouchBackend.js?");
var invariant = function invariant(condition, format, a, b, c, d, e, f) {
if (NODE_ENV !== 'production') {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
/***/ }),
if (!condition) {
var error;
/***/ "./lib/index.js":
/*!**********************!*\
!*** ./lib/index.js ***!
\**********************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
if (format === undefined) {
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _TouchBackend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TouchBackend */ \"./lib/TouchBackend.js\");\n\nconst createTouchBackendFactory = (manager, context, options = {}) => new _TouchBackend__WEBPACK_IMPORTED_MODULE_0__[\"default\"](manager, context, options);\n/* harmony default export */ __webpack_exports__[\"default\"] = (createTouchBackendFactory);\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/index.js?");
error.framesToPop = 1; // we don't care about invariant's own frame
/***/ }),
throw error;
}
};
/***/ "./lib/interfaces.js":
/*!***************************!*\
!*** ./lib/interfaces.js ***!
\***************************/
/*! exports provided: ListenerType */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
var invariant_1 = invariant;
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ListenerType\", function() { return ListenerType; });\nvar ListenerType;\n(function (ListenerType) {\n ListenerType[\"mouse\"] = \"mouse\";\n ListenerType[\"touch\"] = \"touch\";\n ListenerType[\"keyboard\"] = \"keyboard\";\n})(ListenerType || (ListenerType = {}));\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/interfaces.js?");
var ListenerType;
/***/ }),
(function (ListenerType) {
ListenerType["mouse"] = "mouse";
ListenerType["touch"] = "touch";
ListenerType["keyboard"] = "keyboard";
})(ListenerType || (ListenerType = {}));
/***/ "./lib/utils/math.js":
/*!***************************!*\
!*** ./lib/utils/math.js ***!
\***************************/
/*! exports provided: distance, inAngleRanges */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
// Used for MouseEvent.buttons (note the s on the end).
var MouseButtons = {
Left: 1,
Right: 2,
Center: 4
}; // Used for e.button (note the lack of an s on the end).
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"distance\", function() { return distance; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"inAngleRanges\", function() { return inAngleRanges; });\nfunction distance(x1, y1, x2, y2) {\n return Math.sqrt(Math.pow(Math.abs(x2 - x1), 2) + Math.pow(Math.abs(y2 - y1), 2));\n}\nfunction inAngleRanges(x1, y1, x2, y2, angleRanges) {\n if (!angleRanges) {\n return false;\n }\n const angle = (Math.atan2(y2 - y1, x2 - x1) * 180) / Math.PI + 180;\n for (let i = 0; i < angleRanges.length; ++i) {\n if ((angleRanges[i].start == null || angle >= angleRanges[i].start) &&\n (angleRanges[i].end == null || angle <= angleRanges[i].end)) {\n return true;\n }\n }\n return false;\n}\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/utils/math.js?");
var MouseButton = {
Left: 0,
Center: 1,
Right: 2
};
/**
* Only touch events and mouse events where the left button is pressed should initiate a drag.
* @param {MouseEvent | TouchEvent} e The event
*/
/***/ }),
function eventShouldStartDrag(e) {
// For touch events, button will be undefined. If e.button is defined,
// then it should be MouseButton.Left.
return e.button === undefined || e.button === MouseButton.Left;
}
/**
* Only touch events and mouse events where the left mouse button is no longer held should end a drag.
* It's possible the user mouse downs with the left mouse button, then mouse down and ups with the right mouse button.
* We don't want releasing the right mouse button to end the drag.
* @param {MouseEvent | TouchEvent} e The event
*/
/***/ "./lib/utils/offsets.js":
/*!******************************!*\
!*** ./lib/utils/offsets.js ***!
\******************************/
/*! exports provided: getNodeClientOffset, getEventClientTouchOffset, getEventClientOffset */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
function eventShouldEndDrag(e) {
// Touch events will have buttons be undefined, while mouse events will have e.buttons's left button
// bit field unset if the left mouse button has been released
return e.buttons === undefined || (e.buttons & MouseButtons.Left) === 0;
}
function isTouchEvent(e) {
return !!e.targetTouches;
}
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getNodeClientOffset\", function() { return getNodeClientOffset; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getEventClientTouchOffset\", function() { return getEventClientTouchOffset; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getEventClientOffset\", function() { return getEventClientOffset; });\n/* harmony import */ var _predicates__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./predicates */ \"./lib/utils/predicates.js\");\n\nconst ELEMENT_NODE = 1;\nfunction getNodeClientOffset(node) {\n const el = node.nodeType === ELEMENT_NODE ? node : node.parentElement;\n if (!el) {\n return undefined;\n }\n const { top, left } = el.getBoundingClientRect();\n return { x: left, y: top };\n}\nfunction getEventClientTouchOffset(e) {\n if (e.targetTouches.length === 1) {\n return getEventClientOffset(e.targetTouches[0]);\n }\n}\nfunction getEventClientOffset(e) {\n if (Object(_predicates__WEBPACK_IMPORTED_MODULE_0__[\"isTouchEvent\"])(e)) {\n return getEventClientTouchOffset(e);\n }\n else {\n return {\n x: e.clientX,\n y: e.clientY,\n };\n }\n}\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/utils/offsets.js?");
var ELEMENT_NODE = 1;
function getNodeClientOffset(node) {
var el = node.nodeType === ELEMENT_NODE ? node : node.parentElement;
/***/ }),
if (!el) {
return undefined;
}
/***/ "./lib/utils/predicates.js":
/*!*********************************!*\
!*** ./lib/utils/predicates.js ***!
\*********************************/
/*! exports provided: eventShouldStartDrag, eventShouldEndDrag, isTouchEvent */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
var _el$getBoundingClient = el.getBoundingClientRect(),
top = _el$getBoundingClient.top,
left = _el$getBoundingClient.left;
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"eventShouldStartDrag\", function() { return eventShouldStartDrag; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"eventShouldEndDrag\", function() { return eventShouldEndDrag; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"isTouchEvent\", function() { return isTouchEvent; });\n// Used for MouseEvent.buttons (note the s on the end).\nconst MouseButtons = {\n Left: 1,\n Right: 2,\n Center: 4,\n};\n// Used for e.button (note the lack of an s on the end).\nconst MouseButton = {\n Left: 0,\n Center: 1,\n Right: 2,\n};\n/**\n * Only touch events and mouse events where the left button is pressed should initiate a drag.\n * @param {MouseEvent | TouchEvent} e The event\n */\nfunction eventShouldStartDrag(e) {\n // For touch events, button will be undefined. If e.button is defined,\n // then it should be MouseButton.Left.\n return e.button === undefined || e.button === MouseButton.Left;\n}\n/**\n * Only touch events and mouse events where the left mouse button is no longer held should end a drag.\n * It's possible the user mouse downs with the left mouse button, then mouse down and ups with the right mouse button.\n * We don't want releasing the right mouse button to end the drag.\n * @param {MouseEvent | TouchEvent} e The event\n */\nfunction eventShouldEndDrag(e) {\n // Touch events will have buttons be undefined, while mouse events will have e.buttons's left button\n // bit field unset if the left mouse button has been released\n return e.buttons === undefined || (e.buttons & MouseButtons.Left) === 0;\n}\nfunction isTouchEvent(e) {\n return !!e.targetTouches;\n}\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/utils/predicates.js?");
return {
x: left,
y: top
};
}
function getEventClientTouchOffset(e) {
if (e.targetTouches.length === 1) {
return getEventClientOffset(e.targetTouches[0]);
}
}
function getEventClientOffset(e) {
if (isTouchEvent(e)) {
return getEventClientTouchOffset(e);
} else {
return {
x: e.clientX,
y: e.clientY
};
}
}
/***/ }),
function distance(x1, y1, x2, y2) {
return Math.sqrt(Math.pow(Math.abs(x2 - x1), 2) + Math.pow(Math.abs(y2 - y1), 2));
}
function inAngleRanges(x1, y1, x2, y2, angleRanges) {
if (!angleRanges) {
return false;
}
/***/ "./lib/utils/supportsPassive.js":
/*!**************************************!*\
!*** ./lib/utils/supportsPassive.js ***!
\**************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
var angle = Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI + 180;
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\nconst supportsPassive = (() => {\n // simular to jQuery's test\n let supported = false;\n try {\n addEventListener('test', () => { }, Object.defineProperty({}, 'passive', {\n get() {\n supported = true;\n return true;\n },\n }));\n }\n catch (e) {\n // do nothing\n }\n return supported;\n})();\n/* harmony default export */ __webpack_exports__[\"default\"] = (supportsPassive);\n\n\n//# sourceURL=webpack://ReactDnDTouchBackend/./lib/utils/supportsPassive.js?");
for (var i = 0; i < angleRanges.length; ++i) {
if ((angleRanges[i].start == null || angle >= angleRanges[i].start) && (angleRanges[i].end == null || angle <= angleRanges[i].end)) {
return true;
}
}
/***/ })
return false;
}
/******/ });
});
var supportsPassive = function () {
// simular to jQuery's test
var supported = false;
try {
addEventListener('test', function () {}, Object.defineProperty({}, 'passive', {
get: function get() {
supported = true;
return true;
}
}));
} catch (e) {// do nothing
}
return supported;
}();
var OptionsReader =
/*#__PURE__*/
function () {
function OptionsReader(incoming, context) {
var _this = this;
_classCallCheck(this, OptionsReader);
this.enableTouchEvents = true;
this.enableMouseEvents = false;
this.enableKeyboardEvents = false;
this.ignoreContextMenu = false;
this.enableHoverOutsideTarget = false;
this.touchSlop = 0;
this.scrollAngleRanges = undefined;
this.context = context;
this.delayTouchStart = incoming.delayTouchStart || incoming.delay || 0;
this.delayMouseStart = incoming.delayMouseStart || incoming.delay || 0;
Object.keys(incoming).forEach(function (key) {
if (incoming[key] != null) {
_this[key] = incoming[key];
}
});
}
_createClass(OptionsReader, [{
key: "window",
get: function get() {
if (this.context && this.context.window) {
return this.context.window;
} else if (typeof window !== 'undefined') {
return window;
}
return undefined;
}
}, {
key: "document",
get: function get() {
if (this.window) {
return this.window.document;
}
return undefined;
}
}]);
return OptionsReader;
}();
var _eventNames;
var eventNames = (_eventNames = {}, _defineProperty(_eventNames, ListenerType.mouse, {
start: 'mousedown',
move: 'mousemove',
end: 'mouseup',
contextmenu: 'contextmenu'
}), _defineProperty(_eventNames, ListenerType.touch, {
start: 'touchstart',
move: 'touchmove',
end: 'touchend'
}), _defineProperty(_eventNames, ListenerType.keyboard, {
keydown: 'keydown'
}), _eventNames);
var TouchBackend =
/*#__PURE__*/
function () {
function TouchBackend(manager, context, options) {
var _this = this;
_classCallCheck(this, TouchBackend);
this.getSourceClientOffset = function (sourceId) {
return getNodeClientOffset(_this.sourceNodes[sourceId]);
};
this.handleTopMoveStartCapture = function (e) {
if (!eventShouldStartDrag(e)) {
return;
}
_this.moveStartSourceIds = [];
};
this.handleMoveStart = function (sourceId) {
// Just because we received an event doesn't necessarily mean we need to collect drag sources.
// We only collect start collecting drag sources on touch and left mouse events.
if (Array.isArray(_this.moveStartSourceIds)) {
_this.moveStartSourceIds.unshift(sourceId);
}
};
this.handleTopMoveStart = function (e) {
if (!eventShouldStartDrag(e)) {
return;
} // Don't prematurely preventDefault() here since it might:
// 1. Mess up scrolling
// 2. Mess up long tap (which brings up context menu)
// 3. If there's an anchor link as a child, tap won't be triggered on link
var clientOffset = getEventClientOffset(e);
if (clientOffset) {
_this._mouseClientOffset = clientOffset;
}
_this.waitingForDelay = false;
};
this.handleTopMoveStartDelay = function (e) {
if (!eventShouldStartDrag(e)) {
return;
}
var delay = e.type === eventNames.touch.start ? _this.options.delayTouchStart : _this.options.delayMouseStart;
_this.timeout = setTimeout(_this.handleTopMoveStart.bind(_this, e), delay);
_this.waitingForDelay = true;
};
this.handleTopMoveCapture = function () {
_this.dragOverTargetIds = [];
};
this.handleMove = function (_, targetId) {
if (_this.dragOverTargetIds) {
_this.dragOverTargetIds.unshift(targetId);
}
};
this.handleTopMove = function (e) {
if (_this.timeout) {
clearTimeout(_this.timeout);
}
if (!_this.document || _this.waitingForDelay) {
return;
}
var moveStartSourceIds = _this.moveStartSourceIds,
dragOverTargetIds = _this.dragOverTargetIds;
var enableHoverOutsideTarget = _this.options.enableHoverOutsideTarget;
var clientOffset = getEventClientOffset(e);
if (!clientOffset) {
return;
} // If the touch move started as a scroll, or is is between the scroll angles
if (_this._isScrolling || !_this.monitor.isDragging() && inAngleRanges(_this._mouseClientOffset.x || 0, _this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y, _this.options.scrollAngleRanges)) {
_this._isScrolling = true;
return;
} // If we're not dragging and we've moved a little, that counts as a drag start
if (!_this.monitor.isDragging() && // eslint-disable-next-line no-prototype-builtins
_this._mouseClientOffset.hasOwnProperty('x') && moveStartSourceIds && distance(_this._mouseClientOffset.x || 0, _this._mouseClientOffset.y || 0, clientOffset.x, clientOffset.y) > (_this.options.touchSlop ? _this.options.touchSlop : 0)) {
_this.moveStartSourceIds = undefined;
_this.actions.beginDrag(moveStartSourceIds, {
clientOffset: _this._mouseClientOffset,
getSourceClientOffset: _this.getSourceClientOffset,
publishSource: false
});
}
if (!_this.monitor.isDragging()) {
return;
}
var sourceNode = _this.sourceNodes[_this.monitor.getSourceId()];
_this.installSourceNodeRemovalObserver(sourceNode);
_this.actions.publishDragSource();
e.preventDefault(); // Get the node elements of the hovered DropTargets
var dragOverTargetNodes = (dragOverTargetIds || []).map(function (key) {
return _this.targetNodes[key];
}); // Get the a ordered list of nodes that are touched by
var elementsAtPoint = _this.options.getDropTargetElementsAtPoint ? _this.options.getDropTargetElementsAtPoint(clientOffset.x, clientOffset.y, dragOverTargetNodes) : _this.document.elementsFromPoint(clientOffset.x, clientOffset.y); // Extend list with parents that are not receiving elementsFromPoint events (size 0 elements and svg groups)
var elementsAtPointExtended = [];
for (var nodeId in elementsAtPoint) {
// eslint-disable-next-line no-prototype-builtins
if (!elementsAtPoint.hasOwnProperty(nodeId)) {
continue;
}
var currentNode = elementsAtPoint[nodeId];
elementsAtPointExtended.push(currentNode);
while (currentNode) {
currentNode = currentNode.parentElement;
if (elementsAtPointExtended.indexOf(currentNode) === -1) {
elementsAtPointExtended.push(currentNode);
}
}
}
var orderedDragOverTargetIds = elementsAtPointExtended // Filter off nodes that arent a hovered DropTargets nodes
.filter(function (node) {
return dragOverTargetNodes.indexOf(node) > -1;
}) // Map back the nodes elements to targetIds
.map(function (node) {
for (var targetId in _this.targetNodes) {
if (node === _this.targetNodes[targetId]) {
return targetId;
}
}
return undefined;
}) // Filter off possible null rows
.filter(function (node) {
return !!node;
}).filter(function (id, index, ids) {
return ids.indexOf(id) === index;
}); // Invoke hover for drop targets when source node is still over and pointer is outside
if (enableHoverOutsideTarget) {
for (var targetId in _this.targetNodes) {
if (_this.targetNodes[targetId] && _this.targetNodes[targetId].contains(sourceNode) && orderedDragOverTargetIds.indexOf(targetId) === -1) {
orderedDragOverTargetIds.unshift(targetId);
break;
}
}
} // Reverse order because dnd-core reverse it before calling the DropTarget drop methods
orderedDragOverTargetIds.reverse();
_this.actions.hover(orderedDragOverTargetIds, {
clientOffset: clientOffset
});
};
this.handleTopMoveEndCapture = function (e) {
_this._isScrolling = false;
if (!eventShouldEndDrag(e)) {
return;
}
if (!_this.monitor.isDragging() || _this.monitor.didDrop()) {
_this.moveStartSourceIds = undefined;
return;
}
e.preventDefault();
_this._mouseClientOffset = {};
_this.uninstallSourceNodeRemovalObserver();
_this.actions.drop();
_this.actions.endDrag();
};
this.handleCancelOnEscape = function (e) {
if (e.key === 'Escape' && _this.monitor.isDragging()) {
_this._mouseClientOffset = {};
_this.uninstallSourceNodeRemovalObserver();
_this.actions.endDrag();
}
};
this.options = new OptionsReader(options, context);
this.actions = manager.getActions();
this.monitor = manager.getMonitor();
this.sourceNodes = {};
this.sourcePreviewNodes = {};
this.sourcePreviewNodeOptions = {};
this.targetNodes = {};
this.listenerTypes = [];
this._mouseClientOffset = {};
this._isScrolling = false;
if (this.options.enableMouseEvents) {
this.listenerTypes.push(ListenerType.mouse);
}
if (this.options.enableTouchEvents) {
this.listenerTypes.push(ListenerType.touch);
}
if (this.options.enableKeyboardEvents) {
this.listenerTypes.push(ListenerType.keyboard);
}
} // public for test
_createClass(TouchBackend, [{
key: "setup",
value: function setup() {
if (!this.window) {
return;
}
invariant_1(!TouchBackend.isSetUp, 'Cannot have two Touch backends at the same time.');
TouchBackend.isSetUp = true;
this.addEventListener(this.window, 'start', this.getTopMoveStartHandler());
this.addEventListener(this.window, 'start', this.handleTopMoveStartCapture, true);
this.addEventListener(this.window, 'move', this.handleTopMove);
this.addEventListener(this.window, 'move', this.handleTopMoveCapture, true);
this.addEventListener(this.window, 'end', this.handleTopMoveEndCapture, true);
if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {
this.addEventListener(this.window, 'contextmenu', this.handleTopMoveEndCapture);
}
if (this.options.enableKeyboardEvents) {
this.addEventListener(this.window, 'keydown', this.handleCancelOnEscape, true);
}
}
}, {
key: "teardown",
value: function teardown() {
if (!this.window) {
return;
}
TouchBackend.isSetUp = false;
this._mouseClientOffset = {};
this.removeEventListener(this.window, 'start', this.handleTopMoveStartCapture, true);
this.removeEventListener(this.window, 'start', this.handleTopMoveStart);
this.removeEventListener(this.window, 'move', this.handleTopMoveCapture, true);
this.removeEventListener(this.window, 'move', this.handleTopMove);
this.removeEventListener(this.window, 'end', this.handleTopMoveEndCapture, true);
if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {
this.removeEventListener(this.window, 'contextmenu', this.handleTopMoveEndCapture);
}
if (this.options.enableKeyboardEvents) {
this.removeEventListener(this.window, 'keydown', this.handleCancelOnEscape, true);
}
this.uninstallSourceNodeRemovalObserver();
}
}, {
key: "addEventListener",
value: function addEventListener(subject, event, handler, capture) {
var options = supportsPassive ? {
capture: capture,
passive: false
} : capture;
this.listenerTypes.forEach(function (listenerType) {
var evt = eventNames[listenerType][event];
if (evt) {
subject.addEventListener(evt, handler, options);
}
});
}
}, {
key: "removeEventListener",
value: function removeEventListener(subject, event, handler, capture) {
var options = supportsPassive ? {
capture: capture,
passive: false
} : capture;
this.listenerTypes.forEach(function (listenerType) {
var evt = eventNames[listenerType][event];
if (evt) {
subject.removeEventListener(evt, handler, options);
}
});
}
}, {
key: "connectDragSource",
value: function connectDragSource(sourceId, node) {
var _this2 = this;
var handleMoveStart = this.handleMoveStart.bind(this, sourceId);
this.sourceNodes[sourceId] = node;
this.addEventListener(node, 'start', handleMoveStart);
return function () {
delete _this2.sourceNodes[sourceId];
_this2.removeEventListener(node, 'start', handleMoveStart);
};
}
}, {
key: "connectDragPreview",
value: function connectDragPreview(sourceId, node, options) {
var _this3 = this;
this.sourcePreviewNodeOptions[sourceId] = options;
this.sourcePreviewNodes[sourceId] = node;
return function () {
delete _this3.sourcePreviewNodes[sourceId];
delete _this3.sourcePreviewNodeOptions[sourceId];
};
}
}, {
key: "connectDropTarget",
value: function connectDropTarget(targetId, node) {
var _this4 = this;
if (!this.document) {
return function () {
return null;
};
}
var handleMove = function handleMove(e) {
if (!_this4.document || !_this4.monitor.isDragging()) {
return;
}
var coords;
/**
* Grab the coordinates for the current mouse/touch position
*/
switch (e.type) {
case eventNames.mouse.move:
coords = {
x: e.clientX,
y: e.clientY
};
break;
case eventNames.touch.move:
coords = {
x: e.touches[0].clientX,
y: e.touches[0].clientY
};
break;
}
/**
* Use the coordinates to grab the element the drag ended on.
* If the element is the same as the target node (or any of it's children) then we have hit a drop target and can handle the move.
*/
var droppedOn = coords != null ? _this4.document.elementFromPoint(coords.x, coords.y) : undefined;
var childMatch = droppedOn && node.contains(droppedOn);
if (droppedOn === node || childMatch) {
return _this4.handleMove(e, targetId);
}
};
/**
* Attaching the event listener to the body so that touchmove will work while dragging over multiple target elements.
*/
this.addEventListener(this.document.body, 'move', handleMove);
this.targetNodes[targetId] = node;
return function () {
if (_this4.document) {
delete _this4.targetNodes[targetId];
_this4.removeEventListener(_this4.document.body, 'move', handleMove);
}
};
}
}, {
key: "getTopMoveStartHandler",
value: function getTopMoveStartHandler() {
if (!this.options.delayTouchStart && !this.options.delayMouseStart) {
return this.handleTopMoveStart;
}
return this.handleTopMoveStartDelay;
}
}, {
key: "installSourceNodeRemovalObserver",
value: function installSourceNodeRemovalObserver(node) {
var _this5 = this;
this.uninstallSourceNodeRemovalObserver();
this.draggedSourceNode = node;
this.draggedSourceNodeRemovalObserver = new MutationObserver(function () {
if (node && !node.parentElement) {
_this5.resurrectSourceNode();
_this5.uninstallSourceNodeRemovalObserver();
}
});
if (!node || !node.parentElement) {
return;
}
this.draggedSourceNodeRemovalObserver.observe(node.parentElement, {
childList: true
});
}
}, {
key: "resurrectSourceNode",
value: function resurrectSourceNode() {
if (this.document && this.draggedSourceNode) {
this.draggedSourceNode.style.display = 'none';
this.draggedSourceNode.removeAttribute('data-reactid');
this.document.body.appendChild(this.draggedSourceNode);
}
}
}, {
key: "uninstallSourceNodeRemovalObserver",
value: function uninstallSourceNodeRemovalObserver() {
if (this.draggedSourceNodeRemovalObserver) {
this.draggedSourceNodeRemovalObserver.disconnect();
}
this.draggedSourceNodeRemovalObserver = undefined;
this.draggedSourceNode = undefined;
}
}, {
key: "window",
get: function get() {
return this.options.window;
} // public for test
}, {
key: "document",
get: function get() {
if (this.window) {
return this.window.document;
}
return undefined;
}
}]);
return TouchBackend;
}();
var createTouchBackendFactory = function createTouchBackendFactory(manager, context) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return new TouchBackend(manager, context, options);
};
return createTouchBackendFactory;
})));

2

dist/umd/ReactDnDTouchBackend.min.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReactDnDTouchBackend=t():e.ReactDnDTouchBackend=t()}(window,(function(){return function(e){var t={};function o(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)o.d(n,s,function(t){return e[t]}.bind(null,s));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=1)}([function(e,t,o){"use strict";e.exports=function(e,t,o,n,s,i,r,a){if(!e){var h;if(void 0===t)h=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var d=[o,n,s,i,r,a],u=0;(h=new Error(t.replace(/%s/g,(function(){return d[u++]})))).name="Invariant Violation"}throw h.framesToPop=1,h}}},function(e,t,o){"use strict";o.r(t);var n,s=o(0),i=o.n(s);!function(e){e.mouse="mouse",e.touch="touch",e.keyboard="keyboard"}(n||(n={}));const r={Left:1,Right:2,Center:4},a={Left:0,Center:1,Right:2};function h(e){return void 0===e.button||e.button===a.Left}const d=1;function u(e){return function(e){return!!e.targetTouches}(e)?function(e){if(1===e.targetTouches.length)return u(e.targetTouches[0])}(e):{x:e.clientX,y:e.clientY}}var c=(()=>{let e=!1;try{addEventListener("test",()=>{},Object.defineProperty({},"passive",{get:()=>(e=!0,!0)}))}catch(e){}return e})();class l{constructor(e,t){this.enableTouchEvents=!0,this.enableMouseEvents=!1,this.enableKeyboardEvents=!1,this.ignoreContextMenu=!1,this.enableHoverOutsideTarget=!1,this.touchSlop=0,this.scrollAngleRanges=void 0,this.context=t,this.delayTouchStart=e.delayTouchStart||e.delay||0,this.delayMouseStart=e.delayMouseStart||e.delay||0,Object.keys(e).forEach(t=>{null!=e[t]&&(this[t]=e[t])})}get window(){return this.context&&this.context.window?this.context.window:"undefined"!=typeof window?window:void 0}get document(){if(this.window)return this.window.document}}const v={[n.mouse]:{start:"mousedown",move:"mousemove",end:"mouseup",contextmenu:"contextmenu"},[n.touch]:{start:"touchstart",move:"touchmove",end:"touchend"},[n.keyboard]:{keydown:"keydown"}};class p{constructor(e,t,o){this.getSourceClientOffset=e=>(function(e){const t=e.nodeType===d?e:e.parentElement;if(!t)return;const{top:o,left:n}=t.getBoundingClientRect();return{x:n,y:o}})(this.sourceNodes[e]),this.handleTopMoveStartCapture=e=>{h(e)&&(this.moveStartSourceIds=[])},this.handleMoveStart=e=>{Array.isArray(this.moveStartSourceIds)&&this.moveStartSourceIds.unshift(e)},this.handleTopMoveStart=e=>{if(!h(e))return;const t=u(e);t&&(this._mouseClientOffset=t),this.waitingForDelay=!1},this.handleTopMoveStartDelay=e=>{if(!h(e))return;const t=e.type===v.touch.start?this.options.delayTouchStart:this.options.delayMouseStart;this.timeout=setTimeout(this.handleTopMoveStart.bind(this,e),t),this.waitingForDelay=!0},this.handleTopMoveCapture=()=>{this.dragOverTargetIds=[]},this.handleMove=(e,t)=>{this.dragOverTargetIds&&this.dragOverTargetIds.unshift(t)},this.handleTopMove=e=>{if(this.timeout&&clearTimeout(this.timeout),!this.document||this.waitingForDelay)return;const{moveStartSourceIds:t,dragOverTargetIds:o}=this,n=this.options.enableHoverOutsideTarget,s=u(e);if(!s)return;if(this._isScrolling||!this.monitor.isDragging()&&function(e,t,o,n,s){if(!s)return!1;const i=180*Math.atan2(n-t,o-e)/Math.PI+180;for(let e=0;e<s.length;++e)if((null==s[e].start||i>=s[e].start)&&(null==s[e].end||i<=s[e].end))return!0;return!1}(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,s.x,s.y,this.options.scrollAngleRanges))return void(this._isScrolling=!0);if(!this.monitor.isDragging()&&this._mouseClientOffset.hasOwnProperty("x")&&t&&function(e,t,o,n){return Math.sqrt(Math.pow(Math.abs(o-e),2)+Math.pow(Math.abs(n-t),2))}(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,s.x,s.y)>(this.options.touchSlop?this.options.touchSlop:0)&&(this.moveStartSourceIds=void 0,this.actions.beginDrag(t,{clientOffset:this._mouseClientOffset,getSourceClientOffset:this.getSourceClientOffset,publishSource:!1})),!this.monitor.isDragging())return;const i=this.sourceNodes[this.monitor.getSourceId()];this.installSourceNodeRemovalObserver(i),this.actions.publishDragSource(),e.preventDefault();const r=(o||[]).map(e=>this.targetNodes[e]),a=this.options.getDropTargetElementsAtPoint?this.options.getDropTargetElementsAtPoint(s.x,s.y,r):this.document.elementsFromPoint(s.x,s.y),h=[];for(const e in a){if(!a.hasOwnProperty(e))continue;let t=a[e];for(h.push(t);t;)t=t.parentElement,-1===h.indexOf(t)&&h.push(t)}const d=h.filter(e=>r.indexOf(e)>-1).map(e=>{for(const t in this.targetNodes)if(e===this.targetNodes[t])return t}).filter(e=>!!e).filter((e,t,o)=>o.indexOf(e)===t);if(n)for(const e in this.targetNodes)if(this.targetNodes[e]&&this.targetNodes[e].contains(i)&&-1===d.indexOf(e)){d.unshift(e);break}d.reverse(),this.actions.hover(d,{clientOffset:s})},this.handleTopMoveEndCapture=e=>{this._isScrolling=!1,function(e){return void 0===e.buttons||0==(e.buttons&r.Left)}(e)&&(this.monitor.isDragging()&&!this.monitor.didDrop()?(e.preventDefault(),this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.drop(),this.actions.endDrag()):this.moveStartSourceIds=void 0)},this.handleCancelOnEscape=e=>{"Escape"===e.key&&this.monitor.isDragging()&&(this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.endDrag())},this.options=new l(o,t),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.sourceNodes={},this.sourcePreviewNodes={},this.sourcePreviewNodeOptions={},this.targetNodes={},this.listenerTypes=[],this._mouseClientOffset={},this._isScrolling=!1,this.options.enableMouseEvents&&this.listenerTypes.push(n.mouse),this.options.enableTouchEvents&&this.listenerTypes.push(n.touch),this.options.enableKeyboardEvents&&this.listenerTypes.push(n.keyboard)}get window(){return this.options.window}get document(){if(this.window)return this.window.document}setup(){this.window&&(i()(!p.isSetUp,"Cannot have two Touch backends at the same time."),p.isSetUp=!0,this.addEventListener(this.window,"start",this.getTopMoveStartHandler()),this.addEventListener(this.window,"start",this.handleTopMoveStartCapture,!0),this.addEventListener(this.window,"move",this.handleTopMove),this.addEventListener(this.window,"move",this.handleTopMoveCapture,!0),this.addEventListener(this.window,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.addEventListener(this.window,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.addEventListener(this.window,"keydown",this.handleCancelOnEscape,!0))}teardown(){this.window&&(p.isSetUp=!1,this._mouseClientOffset={},this.removeEventListener(this.window,"start",this.handleTopMoveStartCapture,!0),this.removeEventListener(this.window,"start",this.handleTopMoveStart),this.removeEventListener(this.window,"move",this.handleTopMoveCapture,!0),this.removeEventListener(this.window,"move",this.handleTopMove),this.removeEventListener(this.window,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.removeEventListener(this.window,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.removeEventListener(this.window,"keydown",this.handleCancelOnEscape,!0),this.uninstallSourceNodeRemovalObserver())}addEventListener(e,t,o,n){const s=c?{capture:n,passive:!1}:n;this.listenerTypes.forEach((function(n){const i=v[n][t];i&&e.addEventListener(i,o,s)}))}removeEventListener(e,t,o,n){const s=c?{capture:n,passive:!1}:n;this.listenerTypes.forEach((function(n){const i=v[n][t];i&&e.removeEventListener(i,o,s)}))}connectDragSource(e,t){const o=this.handleMoveStart.bind(this,e);return this.sourceNodes[e]=t,this.addEventListener(t,"start",o),()=>{delete this.sourceNodes[e],this.removeEventListener(t,"start",o)}}connectDragPreview(e,t,o){return this.sourcePreviewNodeOptions[e]=o,this.sourcePreviewNodes[e]=t,()=>{delete this.sourcePreviewNodes[e],delete this.sourcePreviewNodeOptions[e]}}connectDropTarget(e,t){if(!this.document)return()=>null;const o=o=>{if(!this.document||!this.monitor.isDragging())return;let n;switch(o.type){case v.mouse.move:n={x:o.clientX,y:o.clientY};break;case v.touch.move:n={x:o.touches[0].clientX,y:o.touches[0].clientY}}const s=null!=n?this.document.elementFromPoint(n.x,n.y):void 0,i=s&&t.contains(s);return s===t||i?this.handleMove(o,e):void 0};return this.addEventListener(this.document.body,"move",o),this.targetNodes[e]=t,()=>{this.document&&(delete this.targetNodes[e],this.removeEventListener(this.document.body,"move",o))}}getTopMoveStartHandler(){return this.options.delayTouchStart||this.options.delayMouseStart?this.handleTopMoveStartDelay:this.handleTopMoveStart}installSourceNodeRemovalObserver(e){this.uninstallSourceNodeRemovalObserver(),this.draggedSourceNode=e,this.draggedSourceNodeRemovalObserver=new MutationObserver(()=>{e&&!e.parentElement&&(this.resurrectSourceNode(),this.uninstallSourceNodeRemovalObserver())}),e&&e.parentElement&&this.draggedSourceNodeRemovalObserver.observe(e.parentElement,{childList:!0})}resurrectSourceNode(){this.document&&this.draggedSourceNode&&(this.draggedSourceNode.style.display="none",this.draggedSourceNode.removeAttribute("data-reactid"),this.document.body.appendChild(this.draggedSourceNode))}uninstallSourceNodeRemovalObserver(){this.draggedSourceNodeRemovalObserver&&this.draggedSourceNodeRemovalObserver.disconnect(),this.draggedSourceNodeRemovalObserver=void 0,this.draggedSourceNode=void 0}}t.default=(e,t,o={})=>new p(e,t,o)}])}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).ReactDnDTouchBackend=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function n(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i,r="production",s=function(e,t,n,o,i,s,a,u){if("production"!==r&&void 0===t)throw new Error("invariant requires an error message argument");if(!e){var d;if(void 0===t)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,i,s,a,u],h=0;(d=new Error(t.replace(/%s/g,(function(){return c[h++]})))).name="Invariant Violation"}throw d.framesToPop=1,d}};!function(e){e.mouse="mouse",e.touch="touch",e.keyboard="keyboard"}(i||(i={}));var a={Left:1,Right:2,Center:4},u={Left:0,Center:1,Right:2};function d(e){return void 0===e.button||e.button===u.Left}var c=1;function h(e){return function(e){return!!e.targetTouches}(e)?function(e){if(1===e.targetTouches.length)return h(e.targetTouches[0])}(e):{x:e.clientX,y:e.clientY}}var l,v=function(){var e=!1;try{addEventListener("test",(function(){}),Object.defineProperty({},"passive",{get:function(){return e=!0,!0}}))}catch(e){}return e}(),f=function(){function t(n,o){var i=this;e(this,t),this.enableTouchEvents=!0,this.enableMouseEvents=!1,this.enableKeyboardEvents=!1,this.ignoreContextMenu=!1,this.enableHoverOutsideTarget=!1,this.touchSlop=0,this.scrollAngleRanges=void 0,this.context=o,this.delayTouchStart=n.delayTouchStart||n.delay||0,this.delayMouseStart=n.delayMouseStart||n.delay||0,Object.keys(n).forEach((function(e){null!=n[e]&&(i[e]=n[e])}))}return n(t,[{key:"window",get:function(){return this.context&&this.context.window?this.context.window:"undefined"!=typeof window?window:void 0}},{key:"document",get:function(){if(this.window)return this.window.document}}]),t}(),p=(o(l={},i.mouse,{start:"mousedown",move:"mousemove",end:"mouseup",contextmenu:"contextmenu"}),o(l,i.touch,{start:"touchstart",move:"touchmove",end:"touchend"}),o(l,i.keyboard,{keydown:"keydown"}),l),m=function(){function t(n,o,r){var s=this;e(this,t),this.getSourceClientOffset=function(e){return function(e){var t=e.nodeType===c?e:e.parentElement;if(t){var n=t.getBoundingClientRect(),o=n.top;return{x:n.left,y:o}}}(s.sourceNodes[e])},this.handleTopMoveStartCapture=function(e){d(e)&&(s.moveStartSourceIds=[])},this.handleMoveStart=function(e){Array.isArray(s.moveStartSourceIds)&&s.moveStartSourceIds.unshift(e)},this.handleTopMoveStart=function(e){if(d(e)){var t=h(e);t&&(s._mouseClientOffset=t),s.waitingForDelay=!1}},this.handleTopMoveStartDelay=function(e){if(d(e)){var t=e.type===p.touch.start?s.options.delayTouchStart:s.options.delayMouseStart;s.timeout=setTimeout(s.handleTopMoveStart.bind(s,e),t),s.waitingForDelay=!0}},this.handleTopMoveCapture=function(){s.dragOverTargetIds=[]},this.handleMove=function(e,t){s.dragOverTargetIds&&s.dragOverTargetIds.unshift(t)},this.handleTopMove=function(e){if(s.timeout&&clearTimeout(s.timeout),s.document&&!s.waitingForDelay){var t,n,o,i,r=s.moveStartSourceIds,a=s.dragOverTargetIds,u=s.options.enableHoverOutsideTarget,d=h(e);if(d)if(s._isScrolling||!s.monitor.isDragging()&&function(e,t,n,o,i){if(!i)return!1;for(var r=180*Math.atan2(o-t,n-e)/Math.PI+180,s=0;s<i.length;++s)if((null==i[s].start||r>=i[s].start)&&(null==i[s].end||r<=i[s].end))return!0;return!1}(s._mouseClientOffset.x||0,s._mouseClientOffset.y||0,d.x,d.y,s.options.scrollAngleRanges))s._isScrolling=!0;else if(!s.monitor.isDragging()&&s._mouseClientOffset.hasOwnProperty("x")&&r&&(t=s._mouseClientOffset.x||0,n=s._mouseClientOffset.y||0,o=d.x,i=d.y,Math.sqrt(Math.pow(Math.abs(o-t),2)+Math.pow(Math.abs(i-n),2))>(s.options.touchSlop?s.options.touchSlop:0))&&(s.moveStartSourceIds=void 0,s.actions.beginDrag(r,{clientOffset:s._mouseClientOffset,getSourceClientOffset:s.getSourceClientOffset,publishSource:!1})),s.monitor.isDragging()){var c=s.sourceNodes[s.monitor.getSourceId()];s.installSourceNodeRemovalObserver(c),s.actions.publishDragSource(),e.preventDefault();var l=(a||[]).map((function(e){return s.targetNodes[e]})),v=s.options.getDropTargetElementsAtPoint?s.options.getDropTargetElementsAtPoint(d.x,d.y,l):s.document.elementsFromPoint(d.x,d.y),f=[];for(var p in v)if(v.hasOwnProperty(p)){var m=v[p];for(f.push(m);m;)m=m.parentElement,-1===f.indexOf(m)&&f.push(m)}var g=f.filter((function(e){return l.indexOf(e)>-1})).map((function(e){for(var t in s.targetNodes)if(e===s.targetNodes[t])return t})).filter((function(e){return!!e})).filter((function(e,t,n){return n.indexOf(e)===t}));if(u)for(var w in s.targetNodes)if(s.targetNodes[w]&&s.targetNodes[w].contains(c)&&-1===g.indexOf(w)){g.unshift(w);break}g.reverse(),s.actions.hover(g,{clientOffset:d})}}},this.handleTopMoveEndCapture=function(e){s._isScrolling=!1,function(e){return void 0===e.buttons||0==(e.buttons&a.Left)}(e)&&(s.monitor.isDragging()&&!s.monitor.didDrop()?(e.preventDefault(),s._mouseClientOffset={},s.uninstallSourceNodeRemovalObserver(),s.actions.drop(),s.actions.endDrag()):s.moveStartSourceIds=void 0)},this.handleCancelOnEscape=function(e){"Escape"===e.key&&s.monitor.isDragging()&&(s._mouseClientOffset={},s.uninstallSourceNodeRemovalObserver(),s.actions.endDrag())},this.options=new f(r,o),this.actions=n.getActions(),this.monitor=n.getMonitor(),this.sourceNodes={},this.sourcePreviewNodes={},this.sourcePreviewNodeOptions={},this.targetNodes={},this.listenerTypes=[],this._mouseClientOffset={},this._isScrolling=!1,this.options.enableMouseEvents&&this.listenerTypes.push(i.mouse),this.options.enableTouchEvents&&this.listenerTypes.push(i.touch),this.options.enableKeyboardEvents&&this.listenerTypes.push(i.keyboard)}return n(t,[{key:"setup",value:function(){this.window&&(s(!t.isSetUp,"Cannot have two Touch backends at the same time."),t.isSetUp=!0,this.addEventListener(this.window,"start",this.getTopMoveStartHandler()),this.addEventListener(this.window,"start",this.handleTopMoveStartCapture,!0),this.addEventListener(this.window,"move",this.handleTopMove),this.addEventListener(this.window,"move",this.handleTopMoveCapture,!0),this.addEventListener(this.window,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.addEventListener(this.window,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.addEventListener(this.window,"keydown",this.handleCancelOnEscape,!0))}},{key:"teardown",value:function(){this.window&&(t.isSetUp=!1,this._mouseClientOffset={},this.removeEventListener(this.window,"start",this.handleTopMoveStartCapture,!0),this.removeEventListener(this.window,"start",this.handleTopMoveStart),this.removeEventListener(this.window,"move",this.handleTopMoveCapture,!0),this.removeEventListener(this.window,"move",this.handleTopMove),this.removeEventListener(this.window,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.removeEventListener(this.window,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.removeEventListener(this.window,"keydown",this.handleCancelOnEscape,!0),this.uninstallSourceNodeRemovalObserver())}},{key:"addEventListener",value:function(e,t,n,o){var i=v?{capture:o,passive:!1}:o;this.listenerTypes.forEach((function(o){var r=p[o][t];r&&e.addEventListener(r,n,i)}))}},{key:"removeEventListener",value:function(e,t,n,o){var i=v?{capture:o,passive:!1}:o;this.listenerTypes.forEach((function(o){var r=p[o][t];r&&e.removeEventListener(r,n,i)}))}},{key:"connectDragSource",value:function(e,t){var n=this,o=this.handleMoveStart.bind(this,e);return this.sourceNodes[e]=t,this.addEventListener(t,"start",o),function(){delete n.sourceNodes[e],n.removeEventListener(t,"start",o)}}},{key:"connectDragPreview",value:function(e,t,n){var o=this;return this.sourcePreviewNodeOptions[e]=n,this.sourcePreviewNodes[e]=t,function(){delete o.sourcePreviewNodes[e],delete o.sourcePreviewNodeOptions[e]}}},{key:"connectDropTarget",value:function(e,t){var n=this;if(!this.document)return function(){return null};var o=function(o){if(n.document&&n.monitor.isDragging()){var i;switch(o.type){case p.mouse.move:i={x:o.clientX,y:o.clientY};break;case p.touch.move:i={x:o.touches[0].clientX,y:o.touches[0].clientY}}var r=null!=i?n.document.elementFromPoint(i.x,i.y):void 0,s=r&&t.contains(r);return r===t||s?n.handleMove(o,e):void 0}};return this.addEventListener(this.document.body,"move",o),this.targetNodes[e]=t,function(){n.document&&(delete n.targetNodes[e],n.removeEventListener(n.document.body,"move",o))}}},{key:"getTopMoveStartHandler",value:function(){return this.options.delayTouchStart||this.options.delayMouseStart?this.handleTopMoveStartDelay:this.handleTopMoveStart}},{key:"installSourceNodeRemovalObserver",value:function(e){var t=this;this.uninstallSourceNodeRemovalObserver(),this.draggedSourceNode=e,this.draggedSourceNodeRemovalObserver=new MutationObserver((function(){e&&!e.parentElement&&(t.resurrectSourceNode(),t.uninstallSourceNodeRemovalObserver())})),e&&e.parentElement&&this.draggedSourceNodeRemovalObserver.observe(e.parentElement,{childList:!0})}},{key:"resurrectSourceNode",value:function(){this.document&&this.draggedSourceNode&&(this.draggedSourceNode.style.display="none",this.draggedSourceNode.removeAttribute("data-reactid"),this.document.body.appendChild(this.draggedSourceNode))}},{key:"uninstallSourceNodeRemovalObserver",value:function(){this.draggedSourceNodeRemovalObserver&&this.draggedSourceNodeRemovalObserver.disconnect(),this.draggedSourceNodeRemovalObserver=void 0,this.draggedSourceNode=void 0}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){if(this.window)return this.window.document}}]),t}();return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new m(e,t,n)}}));

@@ -15,4 +15,4 @@ import { TouchBackendOptions, AngleRange } from './interfaces';

constructor(incoming: TouchBackendOptions, context?: any);
readonly window: any;
readonly document: any;
get window(): any;
get document(): any;
}

@@ -22,4 +22,4 @@ import { Backend, DragDropManager, Unsubscribe } from 'dnd-core';

constructor(manager: DragDropManager, context: any, options: TouchBackendOptions);
readonly window: any;
readonly document: any;
get window(): any;
get document(): any;
setup(): void;

@@ -26,0 +26,0 @@ teardown(): void;

@@ -233,4 +233,3 @@ import invariant from 'invariant';

if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {
this.addEventListener(this.window, 'contextmenu', this
.handleTopMoveEndCapture);
this.addEventListener(this.window, 'contextmenu', this.handleTopMoveEndCapture);
}

@@ -248,4 +247,3 @@ if (this.options.enableKeyboardEvents) {

this.removeEventListener(this.window, 'start', this.handleTopMoveStartCapture, true);
this.removeEventListener(this.window, 'start', this
.handleTopMoveStart);
this.removeEventListener(this.window, 'start', this.handleTopMoveStart);
this.removeEventListener(this.window, 'move', this.handleTopMoveCapture, true);

@@ -255,4 +253,3 @@ this.removeEventListener(this.window, 'move', this.handleTopMove);

if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {
this.removeEventListener(this.window, 'contextmenu', this
.handleTopMoveEndCapture);
this.removeEventListener(this.window, 'contextmenu', this.handleTopMoveEndCapture);
}

@@ -259,0 +256,0 @@ if (this.options.enableKeyboardEvents) {

{
"name": "react-dnd-touch-backend",
"version": "9.4.0",
"version": "9.5.0",
"description": "Touch backend for react-dnd",

@@ -9,2 +9,3 @@ "type": "module",

"types": "lib/index.d.ts",
"sideEffects": false,
"license": "MIT",

@@ -23,6 +24,5 @@ "author": "Long Ho <holevietlong@gmail.com>",

"@types/invariant": "^2.2.30",
"dnd-core": "^9.4.0",
"dnd-core": "^9.5.0",
"invariant": "^2.2.4"
},
"gitHead": "4e80bc3c359dac288fc987326dffd891312e1a16"
}
}

@@ -133,4 +133,7 @@ import invariant from 'invariant'

if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {
this.addEventListener(this.window, 'contextmenu', this
.handleTopMoveEndCapture as any)
this.addEventListener(
this.window,
'contextmenu',
this.handleTopMoveEndCapture as any,
)
}

@@ -162,6 +165,9 @@

)
this.removeEventListener(this.window, 'start', this
.handleTopMoveStart as any)
this.removeEventListener(
this.window,
'start',
this.handleTopMoveStart as any,
)
this.removeEventListener(
this.window,
'move',

@@ -180,4 +186,7 @@ this.handleTopMoveCapture,

if (this.options.enableMouseEvents && !this.options.ignoreContextMenu) {
this.removeEventListener(this.window, 'contextmenu', this
.handleTopMoveEndCapture as any)
this.removeEventListener(
this.window,
'contextmenu',
this.handleTopMoveEndCapture as any,
)
}

@@ -184,0 +193,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc