UNPKG

ngx-drag-and-drop

Version:

Angular library that allow you to build drag and drop without the native HTML5 API

808 lines (776 loc) 34.8 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common')) : typeof define === 'function' && define.amd ? define('ngx-drag-and-drop', ['exports', '@angular/core', '@angular/common'], factory) : (global = global || self, factory(global['ngx-drag-and-drop'] = {}, global.ng.core, global.ng.common)); }(this, (function (exports, core, common) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __exportStar(m, exports) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } var myDoc = document; myDoc.elementsFromPoint = myDoc.elementsFromPoint || function (x, y) { var element; var old_visibility = []; var elements = []; while (true) { element = document.elementFromPoint(x, y); if (!element || element === document.documentElement) { break; } elements.push(element); old_visibility.push(element.style.visibility); element.style.visibility = 'hidden'; // Temporarily hide the element (without changing the layout) } for (var k = 0; k < elements.length; k++) { elements[k].style.visibility = old_visibility[k]; } return elements; }; /* interface ShadowRoot extends DocumentFragment { styleSheets : StyleSheetList; innerHTML : string; host : Element; activeElement : Element; elementFromPoint (x : number, y : number) : Element; elementsFromPoint (x : number, y : number) : Element[]; caretPositionFromPoint (x : number, y : number); // => CaretPosition }; interface ElementWithShadowRoot extends HTMLElement { shadowRoot : ShadowRoot; };*/ var dragPointerId = 'dragPointer'; var DragManager = /** @class */ (function () { function DragManager() { this.draggingPointer = new Map(); this.draggedStructures = new Map(); this.dropZones = new Map(); } DragManager.prototype.preStartDrag = function (idPointer, x, y, delay, dist) { var _this = this; this.draggingPointer.set(idPointer, { x: x, y: y }); return new Promise(function (resolve, reject) { setTimeout(function () { var ptr = _this.draggingPointer.get(idPointer); var gogo = ptr && (Math.abs(x - ptr.x) + Math.abs(y - ptr.y)) < dist; _this.draggingPointer.delete(idPointer); gogo ? resolve() : reject(); }, Math.max(0, delay)); }); }; DragManager.prototype.startDrag = function (idPointer, dragged) { this.draggedStructures.set(idPointer, dragged); var possibleDropZones = new Map(); this.dropZones.forEach(function (dz) { if (dz.checkAccept(dragged)) { dz.appendDropCandidatePointer(idPointer); possibleDropZones.set(dz.root, dz); } }); return possibleDropZones; }; DragManager.prototype.isAssociatedToDropZone = function (element) { return this.dropZones.has(element); }; DragManager.prototype.registerDropZone = function (dropzone) { this.dropZones.set(dropzone.root, dropzone); }; DragManager.prototype.unregisterDropZone = function (dropzone) { this.dropZones.delete(dropzone.root); }; DragManager.prototype.pointerMove = function (idPointer, x, y) { var ptr = this.draggingPointer.get(idPointer); if (ptr) { ptr.x = x; ptr.y = y; } var dragged = this.draggedStructures.get(idPointer); if (dragged && dragged instanceof Draggable) { dragged.move(x, y); } return dragged !== undefined; }; DragManager.prototype.pointerRelease = function (idPointer) { var dragged = this.draggedStructures.get(idPointer); if (dragged) { if (dragged instanceof Draggable) { dragged.stop(); } } this.draggedStructures.delete(idPointer); this.draggingPointer.delete(idPointer); return dragged !== undefined; }; return DragManager; }()); var DM = new DragManager(); var dragDropInit = false; var DragDrop = /** @class */ (function () { function DragDrop() { this.nbDragEnter = 0; if (dragDropInit) { console.error('Do not create multiple instance of directive drag-and-drop-wrapper !'); } else { dragDropInit = true; } } DragDrop.prototype.removeFeedbackForDragPointer = function () { this.nbDragEnter = 0; DM.dropZones.forEach(function (dz) { dz.removePointerHover(dragPointerId); dz.removeDropCandidatePointer(dragPointerId); }); }; DragDrop.prototype.drop = function (e) { e.preventDefault(); e.stopPropagation(); this.removeFeedbackForDragPointer(); }; DragDrop.prototype.dragover = function (e) { e.preventDefault(); e.stopPropagation(); }; DragDrop.prototype.dragenter = function (e) { this.nbDragEnter++; if (this.nbDragEnter === 1) { DM.startDrag(dragPointerId, e); } }; DragDrop.prototype.dragleave = function (e) { this.nbDragEnter--; if (this.nbDragEnter === 0) { this.removeFeedbackForDragPointer(); DM.pointerRelease(dragPointerId); } }; DragDrop.prototype.dragend = function (e) { DM.pointerRelease(dragPointerId); this.removeFeedbackForDragPointer(); e.preventDefault(); }; DragDrop.prototype.mousemove = function (e) { DM.pointerMove('mouse', e.clientX, e.clientY); }; DragDrop.prototype.mouseup = function (e) { DM.pointerRelease('mouse'); }; DragDrop.prototype.touchmove = function (e) { for (var i = 0; i < e.changedTouches.length; i++) { var touch = e.changedTouches.item(i); if (DM.pointerMove(touch.identifier.toString(), touch.clientX, touch.clientY)) { e.preventDefault(); e.stopPropagation(); } } }; DragDrop.prototype.touchend = function (e) { for (var i = 0; i < e.changedTouches.length; i++) { var touch = e.changedTouches.item(i); if (DM.pointerRelease(touch.identifier.toString())) { e.preventDefault(); e.stopPropagation(); } } }; __decorate([ core.HostListener('document: drop', ['$event']) ], DragDrop.prototype, "drop", null); __decorate([ core.HostListener('document: dragover', ['$event']) ], DragDrop.prototype, "dragover", null); __decorate([ core.HostListener('document: dragenter', ['$event']) ], DragDrop.prototype, "dragenter", null); __decorate([ core.HostListener('document: dragleave', ['$event']) ], DragDrop.prototype, "dragleave", null); __decorate([ core.HostListener('document: dragend', ['$event']) ], DragDrop.prototype, "dragend", null); __decorate([ core.HostListener('document: mousemove', ['$event']) ], DragDrop.prototype, "mousemove", null); __decorate([ core.HostListener('document: mouseup', ['$event']) ], DragDrop.prototype, "mouseup", null); __decorate([ core.HostListener('document: touchmove', ['$event']) ], DragDrop.prototype, "touchmove", null); __decorate([ core.HostListener('document: touchend', ['$event']) ], DragDrop.prototype, "touchend", null); DragDrop = __decorate([ core.Directive({ selector: '*[drag-and-drop-wrapper]' }) ], DragDrop); return DragDrop; }()); var offsetElement = function (element) { var left = 0, top = 0; while (element) { top += element.offsetTop - element.scrollTop + element.clientTop; left += element.offsetLeft - element.scrollLeft + element.clientLeft; element = element.offsetParent; } return { left: left, top: top }; }; var ɵ0 = offsetElement; var Draggable = /** @class */ (function () { function Draggable(el) { this.disabled = false; this.onDragStart = new core.EventEmitter(); this.onDragEnd = new core.EventEmitter(); this.isBeingDragged = false; this.cloneNode = null; this.possibleDropZones = new Map(); this.root = el.nativeElement; if (!dragDropInit) { console.error('You should add one dragdrop attribute to your code before using draggable'); } } Draggable.prototype.ngOnInit = function () { // }; Draggable.prototype.ngOnDestroy = function () { // XXX No stop in case of unplug while dragging... : // this.stop(); }; Draggable.prototype.onMouseDown = function (event) { if (!this.disabled) { event.preventDefault(); event.stopPropagation(); this.prestart('mouse', event.clientX, event.clientY); } }; Draggable.prototype.onTouchStart = function (event) { event.stopPropagation(); for (var i = 0; i < event.changedTouches.length; i++) { var touch = event.changedTouches.item(i); this.prestart(touch.identifier.toString(), touch.clientX, touch.clientY); } }; Draggable.prototype.prestart = function (idPointer, x, y) { var _this = this; DM.preStartDrag(idPointer, x, y, this.startDelay || 0, this.startDistance || 10).then(function () { _this.start(idPointer, x, y); }, function () { // console.error('skip the drag'); }); }; Draggable.prototype.start = function (idPointer, x, y) { if (!this.isBeingDragged) { this.isBeingDragged = true; this.idPointer = idPointer; var offset = offsetElement(this.root); this.ox = x; this.oy = y; this.dx = x - offset.left; this.dy = y - offset.top; this.tx = this.root.offsetWidth; this.ty = this.root.offsetHeight; this.getClone(); this.cloneNode.style.left = (x - this.dx) + 'px'; this.cloneNode.style.top = (y - this.dy) + 'px'; this.onDragStart.emit(this.draggedData); this.possibleDropZones = DM.startDrag(idPointer, this); } }; Draggable.prototype.stop = function () { var _this = this; this.possibleDropZones.forEach(function (dz) { dz.removePointerHover(_this.idPointer); dz.removeDropCandidatePointer(_this.idPointer); }); this.isBeingDragged = false; this.possibleDropZones.clear(); this.idPointer = null; if (this.currentDropZone) { this.currentDropZone.drop(this.draggedData); } this.currentDropZone = null; this.onDragEnd.emit(this.draggedData); this.deleteClone(); }; Draggable.prototype.move = function (x, y) { var element = null; if (this.cloneNode === null) { this.getClone(); } if (this.cloneNode) { this.cloneNode.style.left = (x - this.dx) + 'px'; this.cloneNode.style.top = (y - this.dy) + 'px'; var visibility = this.cloneNode.style.visibility; this.cloneNode.style.visibility = 'hidden'; var top_1 = this.cloneNode.style.top; this.cloneNode.style.top = '999999999px'; element = myDoc.elementFromPoint(x, y); this.cloneNode.style.top = top_1; this.cloneNode.style.visibility = visibility; var prevDropZone = this.currentDropZone; while (element) { this.currentDropZone = this.possibleDropZones.get(element); if (this.currentDropZone) { break; } element = element.parentElement; } if (prevDropZone !== this.currentDropZone) { if (prevDropZone) { prevDropZone.removePointerHover(this.idPointer); } if (this.currentDropZone) { this.currentDropZone.appendPointerHover(this.idPointer); } } } return this; }; Draggable.prototype.deepStyle = function (original, clone) { if (original instanceof HTMLElement) { var style = window.getComputedStyle(original); for (var i = 0; i < style.length; i++) { var att = style[i]; clone.style[att] = style[att]; } for (var i = 0; i < original.children.length; i++) { this.deepStyle(original.children.item(i), clone.children.item(i)); } } }; Draggable.prototype.deleteClone = function () { if (this.cloneNode) { if (this.cloneNode.parentNode) { this.cloneNode.parentNode.removeChild(this.cloneNode); } this.cloneNode = null; } }; Draggable.prototype.getClone = function () { if (this.cloneNode === null) { this.cloneNode = this.root.cloneNode(true); this.deepStyle(this.root, this.cloneNode); document.body.appendChild(this.cloneNode); this.cloneNode.style.position = 'absolute'; this.cloneNode.style.zIndex = '999'; this.cloneNode.style.marginLeft = '0'; this.cloneNode.style.marginTop = '0'; this.cloneNode.style.marginRight = '0'; this.cloneNode.style.marginBottom = '0'; this.cloneNode.style.opacity = ''; this.cloneNode.style.cursor = ''; this.cloneNode.style.transform = ''; this.cloneNode.style.transformOrigin = ''; this.cloneNode.style.animation = ''; this.cloneNode.style.transition = ''; this.cloneNode.classList.add('drag-and-drop-clone-node'); } return this.cloneNode; }; Draggable.ctorParameters = function () { return [ { type: core.ElementRef } ]; }; __decorate([ core.Input('draggable') ], Draggable.prototype, "draggedData", void 0); __decorate([ core.Input('drag-start-delay') ], Draggable.prototype, "startDelay", void 0); __decorate([ core.Input('start-distance') ], Draggable.prototype, "startDistance", void 0); __decorate([ core.Input('disabled') ], Draggable.prototype, "disabled", void 0); __decorate([ core.Output('drag-start') ], Draggable.prototype, "onDragStart", void 0); __decorate([ core.Output('drag-end') ], Draggable.prototype, "onDragEnd", void 0); __decorate([ core.HostListener('mousedown', ['$event']) ], Draggable.prototype, "onMouseDown", null); __decorate([ core.HostListener('touchstart', ['$event']) ], Draggable.prototype, "onTouchStart", null); Draggable = __decorate([ core.Directive({ selector: '*[draggable]' }) ], Draggable); return Draggable; }()); var Dropzone = /** @class */ (function () { function Dropzone(el) { this.nbDragEnter = 0; this.onDropEmitter = new core.EventEmitter(); this.onDragStart = new core.EventEmitter(); this.onDragEnd = new core.EventEmitter(); this.onDragEnter = new core.EventEmitter(); this.onDragLeave = new core.EventEmitter(); this.dropCandidateofPointers = []; this.pointersHover = []; if (!dragDropInit) { console.error('You should add one dragdrop attribute to your code before using dropzone'); } this.root = el.nativeElement; DM.registerDropZone(this); } Dropzone.prototype.ngOnInit = function () { // }; Dropzone.prototype.ngOnDestroy = function () { DM.unregisterDropZone(this); }; Dropzone.prototype.BrowserDragEnter = function (event) { this.nbDragEnter++; if (this.nbDragEnter === 1) { this.appendPointerHover(dragPointerId); } }; Dropzone.prototype.BrowserDragLeave = function (event) { this.nbDragEnter--; if (this.nbDragEnter === 0) { this.removePointerHover(dragPointerId); } }; Dropzone.prototype.BrowserDrop = function (event) { DM.pointerRelease(dragPointerId); this.nbDragEnter = 0; this.onDropEmitter.emit(event); }; Dropzone.prototype.drop = function (obj) { this.onDropEmitter.emit(obj); }; Dropzone.prototype.checkAccept = function (drag) { var res; if (drag instanceof Draggable) { res = this.acceptFunction ? this.acceptFunction(drag.draggedData) : true; } else { res = this.acceptFunction ? this.acceptFunction(drag) : true; } return res; }; Dropzone.prototype.hasPointerHover = function (idPointer) { return this.pointersHover.indexOf(idPointer) >= 0; }; Dropzone.prototype.appendPointerHover = function (idPointer) { if (this.pointersHover.indexOf(idPointer) === -1) { var dragged = DM.draggedStructures.get(idPointer); this.pointersHover.push(idPointer); if (dragged instanceof Draggable) { if (this.dragOverCSS_pointer) { dragged.getClone().classList.add(this.dragOverCSS_pointer); } this.onDragEnter.emit(dragged.draggedData); } else { this.onDragEnter.emit(dragged); } if (this.dragOverCSS) { this.root.classList.add(this.dragOverCSS); } } }; Dropzone.prototype.removePointerHover = function (idPointer) { var pos = this.pointersHover.indexOf(idPointer); if (pos >= 0) { var dragged = DM.draggedStructures.get(idPointer); this.pointersHover.splice(pos, 1); if (dragged instanceof Draggable) { if (this.dragOverCSS_pointer) { dragged.getClone().classList.remove(this.dragOverCSS_pointer); } this.onDragLeave.emit(dragged.draggedData); } else { this.onDragLeave.emit(dragged); } if (this.pointersHover.length === 0 && this.dragOverCSS) { this.root.classList.remove(this.dragOverCSS); } } }; Dropzone.prototype.appendDropCandidatePointer = function (idPointer) { if (this.dropCandidateofPointers.indexOf(idPointer) === -1) { var dragged = DM.draggedStructures.get(idPointer); if (dragged instanceof Draggable) { this.onDragStart.emit(dragged.draggedData); } else { this.onDragStart.emit(dragged); } this.dropCandidateofPointers.push(idPointer); if (this.dragCSS) { this.root.classList.add(this.dragCSS); } } }; Dropzone.prototype.removeDropCandidatePointer = function (idPointer) { var pos = this.dropCandidateofPointers.indexOf(idPointer); if (pos >= 0) { var dragged = DM.draggedStructures.get(idPointer); if (dragged instanceof Draggable) { this.onDragEnd.emit(dragged.draggedData); } else { this.onDragEnd.emit(dragged); } this.dropCandidateofPointers.splice(pos, 1); if (this.dropCandidateofPointers.length === 0 && this.dragCSS) { this.root.classList.remove(this.dragCSS); } } }; Dropzone.ctorParameters = function () { return [ { type: core.ElementRef } ]; }; __decorate([ core.Input('drag-css') ], Dropzone.prototype, "dragCSS", void 0); __decorate([ core.Input('drag-over-css') ], Dropzone.prototype, "dragOverCSS", void 0); __decorate([ core.Input('drag-over-css-for-draggable') ], Dropzone.prototype, "dragOverCSS_pointer", void 0); __decorate([ core.Input('accept-function') ], Dropzone.prototype, "acceptFunction", void 0); __decorate([ core.Output('ondrop') ], Dropzone.prototype, "onDropEmitter", void 0); __decorate([ core.Output('drag-start') ], Dropzone.prototype, "onDragStart", void 0); __decorate([ core.Output('drag-end') ], Dropzone.prototype, "onDragEnd", void 0); __decorate([ core.Output('drag-enter') ], Dropzone.prototype, "onDragEnter", void 0); __decorate([ core.Output('drag-leave') ], Dropzone.prototype, "onDragLeave", void 0); __decorate([ core.HostListener('dragenter', ['$event']) ], Dropzone.prototype, "BrowserDragEnter", null); __decorate([ core.HostListener('dragleave', ['$event']) ], Dropzone.prototype, "BrowserDragLeave", null); __decorate([ core.HostListener('drop', ['$event']) ], Dropzone.prototype, "BrowserDrop", null); Dropzone = __decorate([ core.Directive({ selector: '*[dropzone]' }) ], Dropzone); return Dropzone; }()); var NgxDragAndDropModule = /** @class */ (function () { function NgxDragAndDropModule() { } NgxDragAndDropModule_1 = NgxDragAndDropModule; NgxDragAndDropModule.forRoot = function () { return { ngModule: NgxDragAndDropModule_1, providers: [] }; }; var NgxDragAndDropModule_1; NgxDragAndDropModule = NgxDragAndDropModule_1 = __decorate([ core.NgModule({ imports: [ common.CommonModule, ], declarations: [ Draggable, Dropzone, DragDrop, ], exports: [ Draggable, Dropzone, DragDrop, ] }) ], NgxDragAndDropModule); return NgxDragAndDropModule; }()); exports.NgxDragAndDropModule = NgxDragAndDropModule; exports.ɵa = DragDrop; exports.ɵb = Draggable; exports.ɵc = Dropzone; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=ngx-drag-and-drop.umd.js.map