UNPKG

ng-drag-and-drop

Version:
2 lines 2.49 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ng-drag-and-drop",["exports","@angular/core"],t):t((e=e||self)["ng-drag-and-drop"]={},e.ng.core)}(this,function(e,t){"use strict";var r=function(){function e(){}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),n=function(){function e(e){this.elementRef=e}return e.prototype.ngOnInit=function(){var e=this,t=this.elementRef.nativeElement;t.draggable="true",t.addEventListener("dragstart",function(r){t.classList.add("drag-src"),e.setDefaultStyle(),r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text",JSON.stringify(e.dragdata))}),t.addEventListener("dragend",function(r){r.preventDefault(),e.removeStyle(),t.classList.remove("drag-src")})},e.prototype.setDefaultStyle=function(){var e=this.elementRef.nativeElement;e.style.backgroundColor="#ccc",e.style.color="#fff",e.style.padding="5px",e.style.margin="1px"},e.prototype.removeStyle=function(){this.elementRef.nativeElement.removeAttribute("style")},e.decorators=[{type:t.Directive,args:[{selector:"[dragMe]"}]}],e.ctorParameters=function(){return[{type:t.ElementRef}]},e.propDecorators={dragdata:[{type:t.Input}]},e}(),o=function(){function e(e){this.elementRef=e,this.dropped=new t.EventEmitter}return e.prototype.ngOnInit=function(){var e=this,t=this.elementRef.nativeElement;t.addEventListener("dragenter",function(e){t.classList.add("over")}),t.addEventListener("dragleave",function(e){t.classList.remove("over")}),t.addEventListener("dragover",function(e){return e.preventDefault&&e.preventDefault(),e.dataTransfer.dropEffect="move",!1}),t.addEventListener("drop",function(r){r.stopPropagation&&r.stopPropagation(),t.classList.remove("over");var n=JSON.parse(r.dataTransfer.getData("text"));return e.dropped.emit(n),!1})},e.decorators=[{type:t.Directive,args:[{selector:"[dropHere]"}]}],e.ctorParameters=function(){return[{type:t.ElementRef}]},e.propDecorators={dropped:[{type:t.Output}]},e}(),a=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[n,o],imports:[],exports:[n,o]}]}],e}();e.DragMeModule=a,e.DragMeService=r,e.DraggerDirective=n,e.DropperDirective=o,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-drag-and-drop.umd.min.js.map