UNPKG

@lumico/angular-gridster2

Version:
1 lines 68.6 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("angular-gridster2",["exports","@angular/core","@angular/common"],e):e((t=t||self)["angular-gridster2"]={},t.ng.core,t.ng.common)}(this,function(t,e,i){"use strict";var s,r,o,h,n,d,l,a,m,p=function(){return(p=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},c={Fit:"fit",ScrollVertical:"scrollVertical",ScrollHorizontal:"scrollHorizontal",Fixed:"fixed",VerticalFixed:"verticalFixed",HorizontalFixed:"horizontalFixed"},g={Always:"always",OnDragAndResize:"onDrag&Resize",None:"none"},u={None:"none",CompactUp:"compactUp",CompactLeft:"compactLeft",CompactUpAndLeft:"compactUp&Left",CompactLeftAndUp:"compactLeft&Up",CompactRight:"compactRight",CompactUpAndRight:"compactUp&Right",CompactRightAndUp:"compactRight&Up"},f={gridType:c.Fit,fixedColWidth:250,fixedRowHeight:250,keepFixedHeightInMobile:!1,keepFixedWidthInMobile:!1,setGridSize:!1,compactType:u.None,mobileBreakpoint:640,minCols:1,maxCols:100,minRows:1,maxRows:100,defaultItemCols:1,defaultItemRows:1,maxItemCols:50,maxItemRows:50,minItemCols:1,minItemRows:1,minItemArea:1,maxItemArea:2500,margin:10,outerMargin:!0,outerMarginTop:null,outerMarginRight:null,outerMarginBottom:null,outerMarginLeft:null,useTransformPositioning:!0,scrollSensitivity:10,scrollSpeed:20,initCallback:undefined,destroyCallback:undefined,gridSizeChangedCallback:undefined,itemChangeCallback:undefined,itemResizeCallback:undefined,itemInitCallback:undefined,itemRemovedCallback:undefined,itemValidateCallback:undefined,enableEmptyCellClick:!1,enableEmptyCellContextMenu:!1,enableEmptyCellDrop:!1,enableEmptyCellDrag:!1,emptyCellClickCallback:undefined,emptyCellContextMenuCallback:undefined,emptyCellDropCallback:undefined,emptyCellDragCallback:undefined,emptyCellDragMaxCols:50,emptyCellDragMaxRows:50,ignoreMarginInRow:!1,draggable:{delayStart:0,enabled:!1,ignoreContentClass:"gridster-item-content",ignoreContent:!1,dragHandleClass:"drag-handler",stop:undefined,start:undefined,dropOverItems:!1,dropOverItemsCallback:undefined},resizable:{delayStart:0,enabled:!1,handles:{s:!0,e:!0,n:!0,w:!0,se:!0,ne:!0,sw:!0,nw:!0},stop:undefined,start:undefined},swap:!0,pushItems:!1,disablePushOnDrag:!1,disablePushOnResize:!1,pushDirections:{north:!0,east:!0,south:!0,west:!0},pushResizeItems:!1,displayGrid:g.OnDragAndResize,disableWindowResize:!1,disableWarnings:!1,scrollToNewItems:!1,disableScrollHorizontal:!1,disableScrollVertical:!1,disableAutoPositionOnConflict:!1},y=function(){function t(){}return t.merge=function(e,i,s){for(var r in i)void 0!==i[r]&&s.hasOwnProperty(r)&&("object"==typeof i[r]?e[r]=t.merge(e[r],i[r],s[r]):e[r]=i[r]);return e},t.debounce=function(t,e){var i;return function(){var s=this,r=arguments,o=function(){i=null,t.apply(s,r)};clearTimeout(i),i=setTimeout(o,e)}},t.checkTouchEvent=function(t){t.clientX===undefined&&t.touches&&(t.touches&&t.touches.length?(t.clientX=t.touches[0].clientX,t.clientY=t.touches[0].clientY):t.changedTouches&&t.changedTouches.length&&(t.clientX=t.changedTouches[0].clientX,t.clientY=t.changedTouches[0].clientY))},t.checkContentClassForEvent=function(e,i){if(e.$options.draggable.ignoreContent){if(!t.checkContentClass(i.target,i.currentTarget,e.$options.draggable.dragHandleClass))return!0}else if(t.checkContentClass(i.target,i.currentTarget,e.$options.draggable.ignoreContentClass))return!0;return!1},t.checkContentClassForEmptyCellClickEvent=function(e,i){return t.checkContentClass(i.target,i.currentTarget,e.$options.draggable.ignoreContentClass)||t.checkContentClass(i.target,i.currentTarget,e.$options.draggable.dragHandleClass)},t.checkContentClass=function(e,i,s){return!(!e||e===i)&&(!!(e.hasAttribute("class")&&e.getAttribute("class").split(" ").indexOf(s)>-1)||t.checkContentClass(e.parentNode,i,s))},t.compareItems=function(t,e){return t.y>e.y?-1:t.y<e.y?1:t.x>e.x?-1:1},t.decorators=[{type:e.Injectable}],t}(),I=function(){},$=function(){function t(t){this.gridster=t}return t.prototype.destroy=function(){delete this.initialItem,delete this.gridster.movingItem,this.gridster.previewStyle&&this.gridster.previewStyle(),delete this.gridster,this.emptyCellExit&&(this.emptyCellExit(),this.emptyCellExit=null)},t.prototype.updateOptions=function(){var t=this;this.gridster.$options.enableEmptyCellClick&&!this.emptyCellClick&&this.gridster.options.emptyCellClickCallback?(this.emptyCellClick=this.gridster.renderer.listen(this.gridster.el,"click",this.emptyCellClickCb.bind(this)),this.emptyCellClickTouch=this.gridster.renderer.listen(this.gridster.el,"touchend",this.emptyCellClickCb.bind(this))):!this.gridster.$options.enableEmptyCellClick&&this.emptyCellClick&&this.emptyCellClickTouch&&(this.emptyCellClick(),this.emptyCellClickTouch(),this.emptyCellClick=null,this.emptyCellClickTouch=null),this.gridster.$options.enableEmptyCellContextMenu&&!this.emptyCellContextMenu&&this.gridster.options.emptyCellContextMenuCallback?this.emptyCellContextMenu=this.gridster.renderer.listen(this.gridster.el,"contextmenu",this.emptyCellContextMenuCb.bind(this)):!this.gridster.$options.enableEmptyCellContextMenu&&this.emptyCellContextMenu&&(this.emptyCellContextMenu(),this.emptyCellContextMenu=null),this.gridster.$options.enableEmptyCellDrop&&!this.emptyCellDrop&&this.gridster.options.emptyCellDropCallback?(this.emptyCellDrop=this.gridster.renderer.listen(this.gridster.el,"drop",this.emptyCellDragDrop.bind(this)),this.gridster.zone.runOutsideAngular(function(){t.emptyCellMove=t.gridster.renderer.listen(t.gridster.el,"dragover",t.emptyCellDragOver.bind(t))}),this.emptyCellExit=this.gridster.renderer.listen("document","dragend",function(){t.gridster.movingItem=null,t.gridster.previewStyle()})):!this.gridster.$options.enableEmptyCellDrop&&this.emptyCellDrop&&this.emptyCellMove&&this.emptyCellExit&&(this.emptyCellDrop(),this.emptyCellMove(),this.emptyCellExit(),this.emptyCellMove=null,this.emptyCellDrop=null,this.emptyCellExit=null),this.gridster.$options.enableEmptyCellDrag&&!this.emptyCellDrag&&this.gridster.options.emptyCellDragCallback?(this.emptyCellDrag=this.gridster.renderer.listen(this.gridster.el,"mousedown",this.emptyCellMouseDown.bind(this)),this.emptyCellDragTouch=this.gridster.renderer.listen(this.gridster.el,"touchstart",this.emptyCellMouseDown.bind(this))):!this.gridster.$options.enableEmptyCellDrag&&this.emptyCellDrag&&this.emptyCellDragTouch&&(this.emptyCellDrag(),this.emptyCellDragTouch(),this.emptyCellDrag=null,this.emptyCellDragTouch=null)},t.prototype.emptyCellClickCb=function(t){if(!this.gridster.movingItem&&!y.checkContentClassForEmptyCellClickEvent(this.gridster,t)){var e=this.getValidItemFromEvent(t);e&&(this.gridster.options.emptyCellClickCallback&&this.gridster.options.emptyCellClickCallback(t,e),this.gridster.cdRef.markForCheck())}},t.prototype.emptyCellContextMenuCb=function(t){if(!this.gridster.movingItem&&!y.checkContentClassForEmptyCellClickEvent(this.gridster,t)){t.preventDefault(),t.stopPropagation();var e=this.getValidItemFromEvent(t);e&&(this.gridster.options.emptyCellContextMenuCallback&&this.gridster.options.emptyCellContextMenuCallback(t,e),this.gridster.cdRef.markForCheck())}},t.prototype.emptyCellDragDrop=function(t){var e=this.getValidItemFromEvent(t);e&&(this.gridster.options.emptyCellDropCallback&&this.gridster.options.emptyCellDropCallback(t,e),this.gridster.cdRef.markForCheck())},t.prototype.emptyCellDragOver=function(t){t.preventDefault(),t.stopPropagation();var e=this.getValidItemFromEvent(t);e?(t.dataTransfer.dropEffect="move",this.gridster.movingItem=e):(t.dataTransfer.dropEffect="none",this.gridster.movingItem=null),this.gridster.previewStyle()},t.prototype.emptyCellMouseDown=function(t){var e=this;if(!y.checkContentClassForEmptyCellClickEvent(this.gridster,t)){t.preventDefault(),t.stopPropagation();var i=this.getValidItemFromEvent(t);i&&1===t.buttons&&(this.initialItem=i,this.gridster.movingItem=i,this.gridster.previewStyle(),this.gridster.zone.runOutsideAngular(function(){e.emptyCellMMove=e.gridster.renderer.listen("window","mousemove",e.emptyCellMouseMove.bind(e)),e.emptyCellMMoveTouch=e.gridster.renderer.listen("window","touchmove",e.emptyCellMouseMove.bind(e))}),this.emptyCellUp=this.gridster.renderer.listen("window","mouseup",this.emptyCellMouseUp.bind(this)),this.emptyCellUpTouch=this.gridster.renderer.listen("window","touchend",this.emptyCellMouseUp.bind(this)))}},t.prototype.emptyCellMouseMove=function(t){t.preventDefault(),t.stopPropagation();var e=this.getValidItemFromEvent(t,this.initialItem);e&&(this.gridster.movingItem=e,this.gridster.previewStyle())},t.prototype.emptyCellMouseUp=function(t){var e=this;this.emptyCellMMove(),this.emptyCellMMoveTouch(),this.emptyCellUp(),this.emptyCellUpTouch();var i=this.getValidItemFromEvent(t,this.initialItem);i&&(this.gridster.movingItem=i),this.gridster.options.emptyCellDragCallback&&this.gridster.movingItem&&this.gridster.options.emptyCellDragCallback(t,this.gridster.movingItem),setTimeout(function(){e.initialItem=null,e.gridster&&(e.gridster.movingItem=null,e.gridster.previewStyle())}),this.gridster.cdRef.markForCheck()},t.prototype.getValidItemFromEvent=function(t,e){t.preventDefault(),t.stopPropagation(),y.checkTouchEvent(t);var i=this.gridster.el.getBoundingClientRect(),s=t.clientX+this.gridster.el.scrollLeft-i.left-this.gridster.$options.margin,r=t.clientY+this.gridster.el.scrollTop-i.top-this.gridster.$options.margin,o={x:this.gridster.pixelsToPositionX(s,Math.floor,!0),y:this.gridster.pixelsToPositionY(r,Math.floor,!0),cols:this.gridster.$options.defaultItemCols,rows:this.gridster.$options.defaultItemRows};if(e&&(o.cols=Math.min(Math.abs(e.x-o.x)+1,this.gridster.$options.emptyCellDragMaxCols),o.rows=Math.min(Math.abs(e.y-o.y)+1,this.gridster.$options.emptyCellDragMaxRows),e.x<o.x?o.x=e.x:e.x-o.x>this.gridster.$options.emptyCellDragMaxCols-1&&(o.x=this.gridster.movingItem?this.gridster.movingItem.x:0),e.y<o.y?o.y=e.y:e.y-o.y>this.gridster.$options.emptyCellDragMaxRows-1&&(o.y=this.gridster.movingItem?this.gridster.movingItem.y:0)),!this.gridster.checkCollision(o))return o},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:I}]},t}(),C=function(){function t(t){this.gridster=t}return t.prototype.destroy=function(){delete this.gridster},t.prototype.checkCompact=function(){this.gridster.$options.compactType!==u.None&&(this.gridster.$options.compactType===u.CompactUp?this.checkCompactUp():this.gridster.$options.compactType===u.CompactLeft?this.checkCompactLeft():this.gridster.$options.compactType===u.CompactUpAndLeft?(this.checkCompactUp(),this.checkCompactLeft()):this.gridster.$options.compactType===u.CompactLeftAndUp?(this.checkCompactLeft(),this.checkCompactUp()):this.gridster.$options.compactType===u.CompactRight?this.checkCompactRight():this.gridster.$options.compactType===u.CompactUpAndRight?(this.checkCompactUp(),this.checkCompactRight()):this.gridster.$options.compactType===u.CompactRightAndUp&&(this.checkCompactRight(),this.checkCompactUp()))},t.prototype.checkCompactItem=function(t){this.gridster.$options.compactType!==u.None&&(this.gridster.$options.compactType===u.CompactUp?this.moveUpTillCollision(t):this.gridster.$options.compactType===u.CompactLeft?this.moveLeftTillCollision(t):this.gridster.$options.compactType===u.CompactUpAndLeft?(this.moveUpTillCollision(t),this.moveLeftTillCollision(t)):this.gridster.$options.compactType===u.CompactLeftAndUp?(this.moveLeftTillCollision(t),this.moveUpTillCollision(t)):this.gridster.$options.compactType===u.CompactUpAndRight&&(this.moveUpTillCollision(t),this.moveRightTillCollision(t)))},t.prototype.checkCompactUp=function(){for(var t,e=!1,i=this.gridster.grid.length,s=0;s<i;s++)!1!==(t=this.gridster.grid[s]).$item.compactEnabled&&this.moveUpTillCollision(t.$item)&&(e=!0,t.item.y=t.$item.y,t.itemChanged());e&&this.checkCompact()},t.prototype.moveUpTillCollision=function(t){return t.y-=1,this.gridster.checkCollision(t)?(t.y+=1,!1):(this.moveUpTillCollision(t),!0)},t.prototype.checkCompactLeft=function(){for(var t,e=!1,i=this.gridster.grid.length,s=0;s<i;s++)!1!==(t=this.gridster.grid[s]).$item.compactEnabled&&this.moveLeftTillCollision(t.$item)&&(e=!0,t.item.x=t.$item.x,t.itemChanged());e&&this.checkCompact()},t.prototype.checkCompactRight=function(){for(var t,e=!1,i=this.gridster.grid.length,s=0;s<i;s++)!1!==(t=this.gridster.grid[s]).$item.compactEnabled&&this.moveRightTillCollision(t.$item)&&(e=!0,t.item.x=t.$item.x,t.itemChanged());e&&this.checkCompact()},t.prototype.moveLeftTillCollision=function(t){return t.x-=1,this.gridster.checkCollision(t)?(t.x+=1,!1):(this.moveLeftTillCollision(t),!0)},t.prototype.moveRightTillCollision=function(t){return t.x+=1,this.gridster.checkCollision(t)?(t.x-=1,!1):(this.moveRightTillCollision(t),!0)},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:I}]},t}(),w=function(){function t(t){this.gridster=t}return t.prototype.destroy=function(){delete this.gridster},t.prototype.updateItem=function(t,e,i){if(this.gridster.mobile)this.clearCellPosition(i,t),this.gridster.$options.keepFixedHeightInMobile?i.setStyle(t,"height",e.rows*this.gridster.$options.fixedRowHeight+"px"):i.setStyle(t,"height",this.gridster.curWidth/2*e.rows+"px"),this.gridster.$options.keepFixedWidthInMobile?i.setStyle(t,"width",this.gridster.$options.fixedColWidth+"px"):i.setStyle(t,"width",""),i.setStyle(t,"margin-bottom",this.gridster.$options.margin+"px"),i.setStyle(t,"margin-right","");else{var s=Math.round(this.gridster.curColWidth*e.x),r=Math.round(this.gridster.curRowHeight*e.y),o=this.gridster.curColWidth*e.cols-this.gridster.$options.margin,h=this.gridster.curRowHeight*e.rows-this.gridster.$options.margin;this.setCellPosition(i,t,s,r),i.setStyle(t,"width",o+"px"),i.setStyle(t,"height",h+"px");var n=null,d=null;this.gridster.$options.outerMargin&&(this.gridster.rows===e.rows+e.y&&(n=null!==this.gridster.$options.outerMarginBottom?this.gridster.$options.outerMarginBottom+"px":this.gridster.$options.margin+"px"),this.gridster.columns===e.cols+e.x&&(d=null!==this.gridster.$options.outerMarginBottom?this.gridster.$options.outerMarginRight+"px":this.gridster.$options.margin+"px")),i.setStyle(t,"margin-bottom",n),i.setStyle(t,"margin-right",d)}},t.prototype.updateGridster=function(){var t="",e="",i="",s="";this.gridster.$options.gridType===c.Fit?(t=c.Fit,e=c.ScrollVertical,i=c.ScrollHorizontal,s=c.Fixed):this.gridster.$options.gridType===c.ScrollVertical?(this.gridster.curRowHeight=this.gridster.curColWidth,t=c.ScrollVertical,e=c.Fit,i=c.ScrollHorizontal,s=c.Fixed):this.gridster.$options.gridType===c.ScrollHorizontal?(this.gridster.curColWidth=this.gridster.curRowHeight,t=c.ScrollHorizontal,e=c.Fit,i=c.ScrollVertical,s=c.Fixed):this.gridster.$options.gridType===c.Fixed?(this.gridster.curColWidth=this.gridster.$options.fixedColWidth+(this.gridster.$options.ignoreMarginInRow?0:this.gridster.$options.margin),this.gridster.curRowHeight=this.gridster.$options.fixedRowHeight+(this.gridster.$options.ignoreMarginInRow?0:this.gridster.$options.margin),t=c.Fixed,e=c.Fit,i=c.ScrollVertical,s=c.ScrollHorizontal):this.gridster.$options.gridType===c.VerticalFixed?(this.gridster.curRowHeight=this.gridster.$options.fixedRowHeight+(this.gridster.$options.ignoreMarginInRow?0:this.gridster.$options.margin),t=c.ScrollVertical,e=c.Fit,i=c.ScrollHorizontal,s=c.Fixed):this.gridster.$options.gridType===c.HorizontalFixed&&(this.gridster.curColWidth=this.gridster.$options.fixedColWidth+(this.gridster.$options.ignoreMarginInRow?0:this.gridster.$options.margin),t=c.ScrollHorizontal,e=c.Fit,i=c.ScrollVertical,s=c.Fixed),this.gridster.mobile?this.gridster.renderer.removeClass(this.gridster.el,t):this.gridster.renderer.addClass(this.gridster.el,t),this.gridster.renderer.removeClass(this.gridster.el,e),this.gridster.renderer.removeClass(this.gridster.el,i),this.gridster.renderer.removeClass(this.gridster.el,s)},t.prototype.getGridColumnStyle=function(t){return p({},this.getLeftPosition(this.gridster.curColWidth*t),{width:this.gridster.curColWidth-this.gridster.$options.margin+"px",height:this.gridster.gridRows.length*this.gridster.curRowHeight-this.gridster.$options.margin+"px"})},t.prototype.getGridRowStyle=function(t){return p({},this.getTopPosition(this.gridster.curRowHeight*t),{width:this.gridster.gridColumns.length*this.gridster.curColWidth-this.gridster.$options.margin+"px",height:this.gridster.curRowHeight-this.gridster.$options.margin+"px"})},t.prototype.getLeftPosition=function(t){return this.gridster.$options.useTransformPositioning?{transform:"translateX("+t+"px)"}:{left:this.getLeftMargin()+t+"px"}},t.prototype.getTopPosition=function(t){return this.gridster.$options.useTransformPositioning?{transform:"translateY("+t+"px)"}:{top:this.getTopMargin()+t+"px"}},t.prototype.clearCellPosition=function(t,e){this.gridster.$options.useTransformPositioning?t.setStyle(e,"transform",""):(t.setStyle(e,"top",""),t.setStyle(e,"left",""))},t.prototype.setCellPosition=function(t,e,i,s){if(this.gridster.$options.useTransformPositioning){var r="translate3d("+i+"px, "+s+"px, 0)";t.setStyle(e,"transform",r)}else t.setStyle(e,"left",this.getLeftMargin()+i+"px"),t.setStyle(e,"top",this.getTopMargin()+s+"px")},t.prototype.getLeftMargin=function(){return this.gridster.$options.outerMargin?null!==this.gridster.$options.outerMarginLeft?this.gridster.$options.outerMarginLeft:this.gridster.$options.margin:0},t.prototype.getTopMargin=function(){return this.gridster.$options.outerMargin?null!==this.gridster.$options.outerMarginTop?this.gridster.$options.outerMarginTop:this.gridster.$options.margin:0},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:I}]},t}(),v=function(){function t(t,e,i,s){this.renderer=e,this.cdRef=i,this.zone=s,this.gridColumns=[],this.gridRows=[],this.el=t.nativeElement,this.$options=JSON.parse(JSON.stringify(f)),this.calculateLayoutDebounce=y.debounce(this.calculateLayout.bind(this),0),this.mobile=!1,this.curWidth=0,this.curHeight=0,this.grid=[],this.curColWidth=0,this.curRowHeight=0,this.dragInProgress=!1,this.emptyCell=new $(this),this.compact=new C(this),this.gridRenderer=new w(this)}return t.checkCollisionTwoItems=function(t,e){return t.x<e.x+e.cols&&t.x+t.cols>e.x&&t.y<e.y+e.rows&&t.y+t.rows>e.y},t.prototype.ngOnInit=function(){this.options.initCallback&&this.options.initCallback(this)},t.prototype.ngOnChanges=function(t){t.options&&(this.setOptions(),this.options=p({},this.options,{api:{optionsChanged:this.optionsChanged.bind(this),resize:this.onResize.bind(this),getNextPossiblePosition:this.getNextPossiblePosition.bind(this),getFirstPossiblePosition:this.getFirstPossiblePosition.bind(this),getLastPossiblePosition:this.getLastPossiblePosition.bind(this)}}),this.columns=this.$options.minCols,this.rows=this.$options.minRows,this.setGridSize(),this.calculateLayout())},t.prototype.resize=function(){var t,e;"fit"!==this.$options.gridType||this.mobile?(e=this.el.clientWidth,t=this.el.clientHeight):(e=this.el.offsetWidth,t=this.el.offsetHeight),e===this.curWidth&&t===this.curHeight||!this.checkIfToResize()||this.onResize()},t.prototype.setOptions=function(){this.$options=y.merge(this.$options,this.options,this.$options),this.$options.disableWindowResize||this.windowResize?this.$options.disableWindowResize&&this.windowResize&&(this.windowResize(),this.windowResize=null):this.windowResize=this.renderer.listen("window","resize",this.onResize.bind(this)),this.emptyCell.updateOptions()},t.prototype.optionsChanged=function(){this.setOptions();for(var t=this.grid.length-1;t>=0;t--)this.grid[t].updateOptions();this.calculateLayout()},t.prototype.ngOnDestroy=function(){this.windowResize&&this.windowResize(),this.options&&this.options.destroyCallback&&this.options.destroyCallback(this),this.options&&this.options.api&&(this.options.api.resize=undefined,this.options.api.optionsChanged=undefined,this.options.api.getNextPossiblePosition=undefined,this.options.api=undefined),this.emptyCell.destroy(),delete this.emptyCell,this.compact.destroy(),delete this.compact},t.prototype.onResize=function(){this.setGridSize(),this.calculateLayout()},t.prototype.checkIfToResize=function(){var t=this.el.clientWidth,e=this.el.offsetWidth,i=this.el.scrollWidth,s=this.el.clientHeight,r=this.el.offsetHeight,o=this.el.scrollHeight;return!(t<e&&o>r&&o-r<e-t)&&!(s<r&&i>e&&i-e<r-s)},t.prototype.setGridSize=function(){var t=this.el,e=t.clientWidth,i=t.clientHeight;this.$options.setGridSize||"fit"===this.$options.gridType&&!this.mobile?(e=t.offsetWidth,i=t.offsetHeight):(e=t.clientWidth,i=t.clientHeight),this.curWidth=e,this.curHeight=i},t.prototype.setGridDimensions=function(){this.setGridSize(),!this.mobile&&this.$options.mobileBreakpoint>this.curWidth?(this.mobile=!this.mobile,this.renderer.addClass(this.el,"mobile")):this.mobile&&this.$options.mobileBreakpoint<this.curWidth&&(this.mobile=!this.mobile,this.renderer.removeClass(this.el,"mobile"));for(var t,e=this.$options.minRows,i=this.$options.minCols,s=this.grid.length-1;s>=0;s--)(t=this.grid[s]).notPlaced||(e=Math.max(e,t.$item.y+t.$item.rows),i=Math.max(i,t.$item.x+t.$item.cols));this.columns===i&&this.rows===e||(this.columns=i,this.rows=e,this.options.gridSizeChangedCallback&&this.options.gridSizeChangedCallback(this))},t.prototype.calculateLayout=function(){if(this.compact&&this.compact.checkCompact(),this.setGridDimensions(),this.$options.outerMargin){var t=-this.$options.margin;null!==this.$options.outerMarginLeft?(t+=this.$options.outerMarginLeft,this.renderer.setStyle(this.el,"padding-left",this.$options.outerMarginLeft+"px")):(t+=this.$options.margin,this.renderer.setStyle(this.el,"padding-left",this.$options.margin+"px")),null!==this.$options.outerMarginRight?(t+=this.$options.outerMarginRight,this.renderer.setStyle(this.el,"padding-right",this.$options.outerMarginRight+"px")):(t+=this.$options.margin,this.renderer.setStyle(this.el,"padding-right",this.$options.margin+"px")),this.curColWidth=(this.curWidth-t)/this.columns;var e=-this.$options.margin;null!==this.$options.outerMarginTop?(e+=this.$options.outerMarginTop,this.renderer.setStyle(this.el,"padding-top",this.$options.outerMarginTop+"px")):(e+=this.$options.margin,this.renderer.setStyle(this.el,"padding-top",this.$options.margin+"px")),null!==this.$options.outerMarginBottom?(e+=this.$options.outerMarginBottom,this.renderer.setStyle(this.el,"padding-bottom",this.$options.outerMarginBottom+"px")):(e+=this.$options.margin,this.renderer.setStyle(this.el,"padding-bottom",this.$options.margin+"px")),this.curRowHeight=(this.curHeight-e)/this.rows}else this.curColWidth=(this.curWidth+this.$options.margin)/this.columns,this.curRowHeight=(this.curHeight+this.$options.margin)/this.rows,this.renderer.setStyle(this.el,"padding-left","0px"),this.renderer.setStyle(this.el,"padding-right","0px"),this.renderer.setStyle(this.el,"padding-top","0px"),this.renderer.setStyle(this.el,"padding-bottom","0px");this.gridRenderer.updateGridster(),this.updateGrid(),this.$options.setGridSize?(this.renderer.setStyle(this.el,"width",this.columns*this.curColWidth+this.$options.margin+"px"),this.renderer.setStyle(this.el,"height",this.rows*this.curRowHeight+this.$options.margin+"px")):(this.renderer.setStyle(this.el,"width",""),this.renderer.setStyle(this.el,"height",""));for(var i,s=this.grid.length-1;s>=0;s--)(i=this.grid[s]).setSize(),i.drag.toggle(),i.resize.toggle();setTimeout(this.resize.bind(this),100)},t.prototype.updateGrid=function(){"always"!==this.$options.displayGrid||this.mobile?"onDrag&Resize"===this.$options.displayGrid&&this.dragInProgress?this.renderer.addClass(this.el,"display-grid"):"none"!==this.$options.displayGrid&&this.dragInProgress&&!this.mobile||this.renderer.removeClass(this.el,"display-grid"):this.renderer.addClass(this.el,"display-grid"),this.setGridDimensions(),this.gridColumns.length=Math.max(this.columns,Math.floor(this.curWidth/this.curColWidth))||0,this.gridRows.length=Math.max(this.rows,Math.floor(this.curHeight/this.curRowHeight))||0,this.cdRef.markForCheck()},t.prototype.addItem=function(t){t.$item.cols===undefined&&(t.$item.cols=this.$options.defaultItemCols,t.item.cols=t.$item.cols,t.itemChanged()),t.$item.rows===undefined&&(t.$item.rows=this.$options.defaultItemRows,t.item.rows=t.$item.rows,t.itemChanged()),-1===t.$item.x||-1===t.$item.y?this.autoPositionItem(t):this.checkCollision(t.$item)&&(this.$options.disableWarnings||(t.notPlaced=!0,console.warn("Can't be placed in the bounds of the dashboard, trying to auto position!/n"+JSON.stringify(t.item,["cols","rows","x","y"]))),this.$options.disableAutoPositionOnConflict?t.notPlaced=!0:this.autoPositionItem(t)),this.grid.push(t),this.calculateLayoutDebounce()},t.prototype.removeItem=function(t){this.grid.splice(this.grid.indexOf(t),1),this.calculateLayoutDebounce(),this.options.itemRemovedCallback&&this.options.itemRemovedCallback(t.item,t)},t.prototype.checkCollision=function(t){var e=!1;if(this.options.itemValidateCallback&&(e=!this.options.itemValidateCallback(t)),!e&&this.checkGridCollision(t)&&(e=!0),!e){var i=this.findItemWithItem(t);i&&(e=i)}return e},t.prototype.checkGridCollision=function(t){var e=t.y>-1&&t.x>-1,i=t.cols+t.x<=this.$options.maxCols,s=t.rows+t.y<=this.$options.maxRows,r=t.maxItemCols===undefined?this.$options.maxItemCols:t.maxItemCols,o=t.minItemCols===undefined?this.$options.minItemCols:t.minItemCols,h=t.maxItemRows===undefined?this.$options.maxItemRows:t.maxItemRows,n=t.minItemRows===undefined?this.$options.minItemRows:t.minItemRows,d=t.cols<=r&&t.cols>=o,l=t.rows<=h&&t.rows>=n,a=t.minItemArea===undefined?this.$options.minItemArea:t.minItemArea,m=t.maxItemArea===undefined?this.$options.maxItemArea:t.maxItemArea,p=t.cols*t.rows;return!(e&&i&&s&&d&&l&&a<=p&&m>=p)},t.prototype.findItemWithItem=function(e){for(var i,s=this.grid.length-1;s>-1;s--)if((i=this.grid[s]).$item!==e&&t.checkCollisionTwoItems(i.$item,e))return i;return!1},t.prototype.findItemsWithItem=function(e){for(var i,s=[],r=this.grid.length-1;r>-1;r--)(i=this.grid[r]).$item!==e&&t.checkCollisionTwoItems(i.$item,e)&&s.push(i);return s},t.prototype.autoPositionItem=function(t){this.getNextPossiblePosition(t.$item)?(t.notPlaced=!1,t.item.x=t.$item.x,t.item.y=t.$item.y,t.itemChanged()):(t.notPlaced=!0,this.$options.disableWarnings||console.warn("Can't be placed in the bounds of the dashboard!/n"+JSON.stringify(t.item,["cols","rows","x","y"])))},t.prototype.getNextPossiblePosition=function(t,e){void 0===e&&(e={}),-1===t.cols&&(t.cols=this.$options.defaultItemCols),-1===t.rows&&(t.rows=this.$options.defaultItemRows),this.setGridDimensions();for(var i,s=e.y||0;s<this.rows;s++)for(t.y=s,i=e.x||0;i<this.columns;i++)if(t.x=i,!this.checkCollision(t))return!0;var r=this.$options.maxRows>=this.rows+t.rows,o=this.$options.maxCols>=this.columns+t.cols;return!(this.rows<=this.columns&&r)&&o?(t.x=this.columns,t.y=0,!0):!!r&&(t.y=this.rows,t.x=0,!0)},t.prototype.getFirstPossiblePosition=function(t){var e=Object.assign({},t);return this.getNextPossiblePosition(e),e},t.prototype.getLastPossiblePosition=function(t){var e={y:0,x:0};e=this.grid.reduce(function(t,e){var i={y:e.$item.y+e.$item.rows-1,x:e.$item.x+e.$item.cols-1};return 1===y.compareItems(t,i)?i:t},e);var i=Object.assign({},t);return this.getNextPossiblePosition(i,e),i},t.prototype.pixelsToPositionX=function(t,e,i){var s=e(t/this.curColWidth);return i?s:Math.max(s,0)},t.prototype.pixelsToPositionY=function(t,e,i){var s=e(t/this.curRowHeight);return i?s:Math.max(s,0)},t.prototype.positionXToPixels=function(t){return t*this.curColWidth},t.prototype.positionYToPixels=function(t){return t*this.curRowHeight},t.decorators=[{type:e.Component,args:[{selector:"gridster",template:'<div class="gridster-column" *ngFor="let column of gridColumns; let i = index;"\n [ngStyle]="gridRenderer.getGridColumnStyle(i)"></div>\n<div class="gridster-row" *ngFor="let row of gridRows; let i = index;"\n [ngStyle]="gridRenderer.getGridRowStyle(i)"></div>\n<ng-content></ng-content>\n<gridster-preview class="gridster-preview"></gridster-preview>\n',encapsulation:e.ViewEncapsulation.None,styles:["gridster{position:relative;box-sizing:border-box;background:grey;width:100%;height:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block}gridster.fit{overflow-x:hidden;overflow-y:hidden}gridster.scrollVertical{overflow-x:hidden;overflow-y:auto}gridster.scrollHorizontal{overflow-x:auto;overflow-y:hidden}gridster.fixed{overflow:auto}gridster.mobile{overflow-x:hidden;overflow-y:auto}gridster.mobile gridster-item{position:relative}gridster .gridster-column,gridster .gridster-row{position:absolute;display:none;transition:.3s;box-sizing:border-box}gridster.display-grid .gridster-column,gridster.display-grid .gridster-row{display:block}gridster .gridster-column{border-left:1px solid #fff;border-right:1px solid #fff}gridster .gridster-row{border-top:1px solid #fff;border-bottom:1px solid #fff}"]}]}],t.ctorParameters=function(){return[{type:e.ElementRef,decorators:[{type:e.Inject,args:[e.ElementRef]}]},{type:e.Renderer2,decorators:[{type:e.Inject,args:[e.Renderer2]}]},{type:e.ChangeDetectorRef,decorators:[{type:e.Inject,args:[e.ChangeDetectorRef]}]},{type:e.NgZone,decorators:[{type:e.Inject,args:[e.NgZone]}]}]},t.propDecorators={options:[{type:e.Input}]},t}(),b=function(){},x=function(){function t(t){this.gridsterItem=t,this.gridster=t.gridster}return t.prototype.destroy=function(){delete this.gridster,delete this.gridsterItem,delete this.swapedItem},t.prototype.swapItems=function(){this.gridster.$options.swap&&(this.checkSwapBack(),this.checkSwap(this.gridsterItem))},t.prototype.checkSwapBack=function(){if(this.swapedItem){var t=this.swapedItem.$item.x,e=this.swapedItem.$item.y;this.swapedItem.$item.x=this.swapedItem.item.x||0,this.swapedItem.$item.y=this.swapedItem.item.y||0,this.gridster.checkCollision(this.swapedItem.$item)?(this.swapedItem.$item.x=t,this.swapedItem.$item.y=e):(this.swapedItem.setSize(),this.gridsterItem.$item.x=this.gridsterItem.item.x||0,this.gridsterItem.$item.y=this.gridsterItem.item.y||0,this.swapedItem=undefined)}},t.prototype.restoreSwapItem=function(){this.swapedItem&&(this.swapedItem.$item.x=this.swapedItem.item.x||0,this.swapedItem.$item.y=this.swapedItem.item.y||0,this.swapedItem.setSize(),this.swapedItem=undefined)},t.prototype.setSwapItem=function(){this.swapedItem&&(this.swapedItem.checkItemChanges(this.swapedItem.$item,this.swapedItem.item),this.swapedItem=undefined)},t.prototype.checkSwap=function(t){var e=this.gridster.checkCollision(t.$item);if(e&&!0!==e&&e.canBeDragged()){var i=e,s=i.$item.x,r=i.$item.y,o=t.$item.x,h=t.$item.y;i.$item.x=t.item.x||0,i.$item.y=t.item.y||0,t.$item.x=i.item.x||0,t.$item.y=i.item.y||0,this.gridster.checkCollision(i.$item)||this.gridster.checkCollision(t.$item)?(t.$item.x=o,t.$item.y=h,i.$item.x=s,i.$item.y=r):(i.setSize(),this.swapedItem=i)}},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:b}]},t}(),k=50;function z(t,e,i,p,c,g,u,f,y,I){s=t.$options.scrollSensitivity,r=t.$options.scrollSpeed,o=t.el,h=y,n=I;var $=o.offsetWidth,C=o.offsetHeight,w=o.scrollLeft,v=o.scrollTop,b=i-v,x=C+v-i-c;if(!t.$options.disableScrollVertical)if(u.clientY<g.clientY&&x<s){if(W(),h&&n&&!n.s||m)return;m=S(1,f,u)}else if(u.clientY>g.clientY&&v>0&&b<s){if(F(),h&&n&&!n.n||a)return;a=S(-1,f,u)}else u.clientY!==g.clientY&&M();var k=w+$-e-p,z=e-w;if(!t.$options.disableScrollHorizontal)if(u.clientX<g.clientX&&k<=s){if(D(),h&&n&&!n.e||d)return;d=P(1,f,u)}else if(u.clientX>g.clientX&&w>0&&z<s){if(E(),h&&n&&!n.w||l)return;l=P(-1,f,u)}else u.clientX!==g.clientX&&R()}function S(t,e,i){var s=i.clientY;return setInterval(function(){(!o||-1===t&&o.scrollTop-r<0)&&M(),o.scrollTop+=t*r,s+=t*r,e({clientX:i.clientX,clientY:s})},k)}function P(t,e,i){var s=i.clientX;return setInterval(function(){(!o||-1===t&&o.scrollLeft-r<0)&&R(),o.scrollLeft+=t*r,e({clientX:s+=t*r,clientY:i.clientY})},k)}function T(){R(),M(),o=undefined}function R(){E(),D()}function M(){W(),F()}function E(){d&&(clearInterval(d),d=0)}function D(){l&&(clearInterval(l),l=0)}function F(){m&&(clearInterval(m),m=0)}function W(){a&&(clearInterval(a),a=0)}var O=function(){function t(t){this.pushedItems=[],this.pushedItemsTemp=[],this.pushedItemsTempPath=[],this.pushedItemsPath=[],this.gridsterItem=t,this.gridster=t.gridster,this.tryPattern={fromEast:[this.tryWest,this.trySouth,this.tryNorth,this.tryEast],fromWest:[this.tryEast,this.trySouth,this.tryNorth,this.tryWest],fromNorth:[this.trySouth,this.tryEast,this.tryWest,this.tryNorth],fromSouth:[this.tryNorth,this.tryEast,this.tryWest,this.trySouth]},this.fromSouth="fromSouth",this.fromNorth="fromNorth",this.fromEast="fromEast",this.fromWest="fromWest"}return t.prototype.destroy=function(){delete this.gridster,delete this.gridsterItem},t.prototype.pushItems=function(t,e){if(this.gridster.$options.pushItems&&!e){this.pushedItemsOrder=[];var i=this.push(this.gridsterItem,t);return i||this.restoreTempItems(),this.pushedItemsOrder=[],this.pushedItemsTemp=[],this.pushedItemsTempPath=[],i}return!1},t.prototype.restoreTempItems=function(){for(var t=this.pushedItemsTemp.length-1;t>-1;t--)this.removeFromTempPushed(this.pushedItemsTemp[t])},t.prototype.restoreItems=function(){for(var t,e=0,i=this.pushedItems.length;e<i;e++)(t=this.pushedItems[e]).$item.x=t.item.x||0,t.$item.y=t.item.y||0,t.setSize();this.pushedItems=[],this.pushedItemsPath=[]},t.prototype.setPushedItems=function(){for(var t,e=0,i=this.pushedItems.length;e<i;e++)(t=this.pushedItems[e]).checkItemChanges(t.$item,t.item);this.pushedItems=[],this.pushedItemsPath=[]},t.prototype.checkPushBack=function(){for(var t=this.pushedItems.length-1,e=!1;t>-1;t--)this.checkPushedItem(this.pushedItems[t],t)&&(e=!0);e&&this.checkPushBack()},t.prototype.push=function(t,e){if(this.gridster.checkGridCollision(t.$item))return!1;if(""===e)return!1;for(var i,s=this.gridster.findItemsWithItem(t.$item),r=s.length-1,o=!0,h=[];r>-1;r--){if((i=s[r])===this.gridsterItem){o=!1;break}if(!i.canBeDragged()){o=!1;break}if(this.pushedItemsTemp.find(function(t){return t.$item.x===i.$item.x&&t.$item.y===i.$item.y})){o=!1;break}if(this.tryPattern[e][0].call(this,i,t))this.pushedItemsOrder.push(i),h.push(i);else if(this.tryPattern[e][1].call(this,i,t))this.pushedItemsOrder.push(i),h.push(i);else if(this.tryPattern[e][2].call(this,i,t))this.pushedItemsOrder.push(i),h.push(i);else{if(!this.tryPattern[e][3].call(this,i,t)){o=!1;break}this.pushedItemsOrder.push(i),h.push(i)}}if(!o&&(r=this.pushedItemsOrder.lastIndexOf(h[0]))>-1)for(var n=this.pushedItemsOrder.length-1;n>=r;n--)i=this.pushedItemsOrder[n],this.pushedItemsOrder.pop(),this.removeFromTempPushed(i),this.removeFromPushedItem(i);return o},t.prototype.trySouth=function(t,e){return!!this.gridster.$options.pushDirections.south&&(this.addToTempPushed(t),t.$item.y=e.$item.y+e.$item.rows,this.push(t,this.fromNorth)?(t.setSize(),this.addToPushed(t),!0):(this.removeFromTempPushed(t),!1))},t.prototype.tryNorth=function(t,e){return!!this.gridster.$options.pushDirections.north&&(this.addToTempPushed(t),t.$item.y=e.$item.y-t.$item.rows,this.push(t,this.fromSouth)?(t.setSize(),this.addToPushed(t),!0):(this.removeFromTempPushed(t),!1))},t.prototype.tryEast=function(t,e){return!!this.gridster.$options.pushDirections.east&&(this.addToTempPushed(t),t.$item.x=e.$item.x+e.$item.cols,this.push(t,this.fromWest)?(t.setSize(),this.addToPushed(t),!0):(this.removeFromTempPushed(t),!1))},t.prototype.tryWest=function(t,e){return!!this.gridster.$options.pushDirections.west&&(this.addToTempPushed(t),t.$item.x=e.$item.x-t.$item.cols,this.push(t,this.fromEast)?(t.setSize(),this.addToPushed(t),!0):(this.removeFromTempPushed(t),!1))},t.prototype.addToTempPushed=function(t){var e=this.pushedItemsTemp.indexOf(t);-1===e&&(e=this.pushedItemsTemp.push(t)-1,this.pushedItemsTempPath[e]=[]),this.pushedItemsTempPath[e].push({x:t.$item.x,y:t.$item.y})},t.prototype.removeFromTempPushed=function(t){var e=this.pushedItemsTemp.indexOf(t),i=this.pushedItemsTempPath[e].pop();i&&(t.$item.x=i.x,t.$item.y=i.y,t.setSize(),this.pushedItemsTempPath[e].length||(this.pushedItemsTemp.splice(e,1),this.pushedItemsTempPath.splice(e,1)))},t.prototype.addToPushed=function(t){if(this.pushedItems.indexOf(t)<0)this.pushedItems.push(t),this.pushedItemsPath.push([{x:t.item.x||0,y:t.item.y||0},{x:t.$item.x,y:t.$item.y}]);else{var e=this.pushedItems.indexOf(t);this.pushedItemsPath[e].push({x:t.$item.x,y:t.$item.y})}},t.prototype.removeFromPushed=function(t){t>-1&&(this.pushedItems.splice(t,1),this.pushedItemsPath.splice(t,1))},t.prototype.removeFromPushedItem=function(t){var e=this.pushedItems.indexOf(t);e>-1&&(this.pushedItemsPath[e].pop(),this.pushedItemsPath.length||(this.pushedItems.splice(e,1),this.pushedItemsPath.splice(e,1)))},t.prototype.checkPushedItem=function(t,e){for(var i,s,r,o=this.pushedItemsPath[e],h=o.length-2,n=!1;h>-1;h--)i=o[h],s=t.$item.x,r=t.$item.y,t.$item.x=i.x,t.$item.y=i.y,this.gridster.findItemWithItem(t.$item)?(t.$item.x=s,t.$item.y=r):(t.setSize(),o.splice(h+1,o.length-h-1),n=!0);return o.length<2&&this.removeFromPushed(e),n},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:b}]},t}(),L=function(){function t(t,e,i){this.zone=i,this.collision=!1,this.gridsterItem=t,this.gridster=e,this.lastMouse={clientX:0,clientY:0},this.path=[]}return t.prototype.destroy=function(){this.gridster.previewStyle&&this.gridster.previewStyle(!0),delete this.gridsterItem,delete this.gridster,delete this.collision,this.mousedown&&(this.mousedown(),this.touchstart())},t.prototype.dragStart=function(t){var e=this;switch(t.which){case 1:break;case 2:case 3:return}this.gridster.options.draggable&&this.gridster.options.draggable.start&&this.gridster.options.draggable.start(this.gridsterItem.item,this.gridsterItem,t),t.stopPropagation(),t.preventDefault(),this.dragFunction=this.dragMove.bind(this),this.dragStopFunction=this.dragStop.bind(this),this.zone.runOutsideAngular(function(){e.mousemove=e.gridsterItem.renderer.listen("document","mousemove",e.dragFunction),e.touchmove=e.gridster.renderer.listen(e.gridster.el,"touchmove",e.dragFunction)}),this.mouseup=this.gridsterItem.renderer.listen("document","mouseup",this.dragStopFunction),this.mouseleave=this.gridsterItem.renderer.listen("document","mouseleave",this.dragStopFunction),this.cancelOnBlur=this.gridsterItem.renderer.listen("window","blur",this.dragStopFunction),this.touchend=this.gridsterItem.renderer.listen("document","touchend",this.dragStopFunction),this.touchcancel=this.gridsterItem.renderer.listen("document","touchcancel",this.dragStopFunction),this.gridsterItem.renderer.addClass(this.gridsterItem.el,"gridster-item-moving"),this.margin=this.gridster.$options.margin,this.offsetLeft=this.gridster.el.scrollLeft-this.gridster.el.offsetLeft,this.offsetTop=this.gridster.el.scrollTop-this.gridster.el.offsetTop,this.left=this.gridsterItem.left-this.margin,this.top=this.gridsterItem.top-this.margin,this.width=this.gridsterItem.width,this.height=this.gridsterItem.height,this.diffLeft=t.clientX+this.offsetLeft-this.margin-this.left,this.diffTop=t.clientY+this.offsetTop-this.margin-this.top,this.gridster.movingItem=this.gridsterItem.$item,this.gridster.previewStyle(!0),this.push=new O(this.gridsterItem),this.swap=new x(this.gridsterItem),this.gridster.dragInProgress=!0,this.gridster.updateGrid(),this.path.push({x:this.gridsterItem.item.x||0,y:this.gridsterItem.item.y||0})},t.prototype.dragMove=function(t){t.stopPropagation(),t.preventDefault(),y.checkTouchEvent(t),this.offsetLeft=this.gridster.el.scrollLeft-this.gridster.el.offsetLeft,this.offsetTop=this.gridster.el.scrollTop-this.gridster.el.offsetTop,z(this.gridster,this.left,this.top,this.width,this.height,t,this.lastMouse,this.calculateItemPositionFromMousePosition.bind(this)),this.calculateItemPositionFromMousePosition(t)},t.prototype.calculateItemPositionFromMousePosition=function(t){var e=this;this.left=t.clientX+this.offsetLeft-this.diffLeft,this.top=t.clientY+this.offsetTop-this.diffTop,this.calculateItemPosition(),this.lastMouse.clientX=t.clientX,this.lastMouse.clientY=t.clientY,this.zone.run(function(){e.gridster.updateGrid()})},t.prototype.dragStop=function(t){var e=this;t.stopPropagation(),t.preventDefault(),T(),this.cancelOnBlur(),this.mousemove(),this.mouseup(),this.mouseleave(),this.touchmove(),this.touchend(),this.touchcancel(),this.gridsterItem.renderer.removeClass(this.gridsterItem.el,"gridster-item-moving"),this.gridster.dragInProgress=!1,this.gridster.updateGrid(),this.path=[],this.gridster.options.draggable&&this.gridster.options.draggable.stop?Promise.resolve(this.gridster.options.draggable.stop(this.gridsterItem.item,this.gridsterItem,t)).then(this.makeDrag.bind(this),this.cancelDrag.bind(this)):this.makeDrag(),setTimeout(function(){e.gridster&&(e.gridster.movingItem=null,e.gridster.previewStyle(!0))})},t.prototype.cancelDrag=function(){this.gridsterItem.$item.x=this.gridsterItem.item.x||0,this.gridsterItem.$item.y=this.gridsterItem.item.y||0,this.gridsterItem.setSize(),this.push&&this.push.restoreItems(),this.swap&&this.swap.restoreSwapItem(),this.push&&(this.push.destroy(),delete this.push),this.swap&&(this.swap.destroy(),delete this.swap)},t.prototype.makeDrag=function(){this.gridster.$options.draggable.dropOverItems&&this.gridster.options.draggable&&this.gridster.options.draggable.dropOverItemsCallback&&this.collision&&!0!==this.collision&&this.collision.$item&&this.gridster.options.draggable.dropOverItemsCallback(this.gridsterItem.item,this.collision.item,this.gridster),this.collision=!1,this.gridsterItem.setSize(),this.gridsterItem.checkItemChanges(this.gridsterItem.$item,this.gridsterItem.item),this.push&&this.push.setPushedItems(),this.swap&&this.swap.setSwapItem(),this.push&&(this.push.destroy(),delete this.push),this.swap&&(this.swap.destroy(),delete this.swap)},t.prototype.calculateItemPosition=function(){if(this.gridster.movingItem=this.gridsterItem.$item,this.positionX=this.gridster.pixelsToPositionX(this.left,Math.round),this.positionY=this.gridster.pixelsToPositionY(this.top,Math.round),this.positionXBackup=this.gridsterItem.$item.x,this.positionYBackup=this.gridsterItem.$item.y,this.gridsterItem.$item.x=this.positionX,this.gridster.checkGridCollision(this.gridsterItem.$item)&&(this.gridsterItem.$item.x=this.positionXBackup),this.gridsterItem.$item.y=this.positionY,this.gridster.checkGridCollision(this.gridsterItem.$item)&&(this.gridsterItem.$item.y=this.positionYBackup),this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer,this.gridsterItem.el,this.left,this.top),this.positionXBackup!==this.gridsterItem.$item.x||this.positionYBackup!==this.gridsterItem.$item.y){var t=this.path[this.path.length-1],e="";t.x<this.gridsterItem.$item.x?e=this.push.fromWest:t.x>this.gridsterItem.$item.x?e=this.push.fromEast:t.y<this.gridsterItem.$item.y?e=this.push.fromNorth:t.y>this.gridsterItem.$item.y&&(e=this.push.fromSouth),this.push.pushItems(e,this.gridster.$options.disablePushOnDrag),this.swap.swapItems(),this.collision=this.gridster.checkCollision(this.gridsterItem.$item),this.collision?(this.gridsterItem.$item.x=this.positionXBackup,this.gridsterItem.$item.y=this.positionYBackup,this.gridster.$options.draggable.dropOverItems&&!0!==this.collision&&this.collision.$item&&(this.gridster.movingItem=null)):this.path.push({x:this.gridsterItem.$item.x,y:this.gridsterItem.$item.y}),this.push.checkPushBack()}this.gridster.previewStyle(!0)},t.prototype.toggle=function(){var t=this.gridsterItem.canBeDragged();!this.enabled&&t?(this.enabled=!this.enabled,this.dragStartFunction=this.dragStartDelay.bind(this),this.mousedown=this.gridsterItem.renderer.listen(this.gridsterItem.el,"mousedown",this.dragStartFunction),this.touchstart=this.gridsterItem.renderer.listen(this.gridsterItem.el,"touchstart",this.dragStartFunction)):this.enabled&&!t&&(this.enabled=!this.enabled,this.mousedown(),this.touchstart())},t.prototype.dragStartDelay=function(t){var e=this;if(!(t.target.hasAttribute("class")&&t.target.getAttribute("class").split(" ").indexOf("gridster-item-resizable-handler")>-1||y.checkContentClassForEvent(this.gridster,t)))if(y.checkTouchEvent(t),this.gridster.$options.draggable.delayStart)var i=setTimeout(function(){e.dragStart(t),l()},this.gridster.$options.draggable.delayStart),s=this.gridsterItem.renderer.listen("document","mouseup",l),r=this.gridsterItem.renderer.listen("document","mouseleave",l),o=this.gridsterItem.renderer.listen("window","blur",l),h=this.gridsterItem.renderer.listen("document","touchmove",function(e){y.checkTouchEvent(e),(Math.abs(e.clientX-t.clientX)>9||Math.abs(e.clientY-t.clientY)>9)&&l()}),n=this.gridsterItem.renderer.listen("document","touchend",l),d=this.gridsterItem.renderer.listen("document","touchcancel",l);else this.dragStart(t);function l(){clearTimeout(i),o(),s(),r(),h(),n(),d()}},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:b},{type:I},{type:e.NgZone}]},t}(),H=function(){function t(t){this.pushedItems=[],this.pushedItemsPath=[],this.gridsterItem=t,this.gridster=t.gridster,this.tryPattern={fromEast:this.tryWest,fromWest:this.tryEast,fromNorth:this.trySouth,fromSouth:this.tryNorth},this.fromSouth="fromSouth",this.fromNorth="fromNorth",this.fromEast="fromEast",this.fromWest="fromWest"}return t.prototype.destroy=function(){delete this.gridster,delete this.gridsterItem},t.prototype.pushItems=function(t){return!!this.gridster.$options.pushResizeItems&&this.push(this.gridsterItem,t)},t.prototype.restoreItems=function(){for(var t,e=0,i=this.pushedItems.length;e<i;e++)(t=this.pushedItems[e]).$item.x=t.item.x||0,t.$item.y=t.item.y||0,t.$item.cols=t.item.cols||1,t.$item.row=t.item.row||1,t.setSize();this.pushedItems=[],this.pushedItemsPath=[]},t.prototype.setPushedItems=function(){for(var t,e=0,i=this.pushedItems.length;e<i;e++)(t=this.pushedItems[e]).checkItemChanges(t.$item,t.item);this.pushedItems=[],this.pushedItemsPath=[]},t.prototype.checkPushBack=function(){for(var t=this.pushedItems.length-1,e=!1;t>-1;t--)this.checkPushedItem(this.pushedItems[t],t)&&(e=!0);e&&this.checkPushBack()},t.prototype.push=function(t,e){var i=this.gridster.checkCollision(t.$item);if(i&&!0!==i&&i!==this.gridsterItem&&i.canBeResized()){if(this.tryPattern[e].call(this,i,t,e))return!0}else if(!1===i)return!0;return!1},t.prototype.trySouth=function(t,e,i){var s=t.$item.y,r=t.$item.rows;return t.$item.y=e.$item.y+e.$item.rows,t.$item.rows=r+s-t.$item.y,v.checkCollisionTwoItems(t.$item,e.$item)||this.gridster.checkGridCollision(t.$item)?(t.$item.y=s,t.$item.rows=r,!1):(t.setSize(),this.addToPushed(t),this.push(e,i),!0)},t.prototype.tryNorth=function(t,e,i){var s=t.$item.rows;return t.$item.rows=e.$item.y-t.$item.y,v.checkCollisionTwoItems(t.$item,e.$item)||this.gridster.checkGridCollision(t.$item)?(t.$item.rows=s,!1):(t.setSize(),this.addToPushed(t),this.push(e,i),!0)},t.prototype.tryEast=function(t,e,i){var s=t.$item.x,r=t.$item.cols;return t.$item.x=e.$item.x+e.$item.cols,t.$item.cols=r+s-t.$item.x,v.checkCollisionTwoItems(t.$item,e.$item)||this.gridster.checkGridCollision(t.$item)?(t.$item.x=s,t.$item.cols=r,!1):(t.setSize(),this.addToPushed(t),this.push(e,i),!0)},t.prototype.tryWest=function(t,e,i){var s=t.$item.cols;return t.$item.cols=e.$item.x-t.$item.x,v.checkCollisionTwoItems(t.$item,e.$item)||this.gridster.checkGridCollision(t.$item)?(t.$item.cols=s,!1):(t.setSize(),this.addToPushed(t),this.push(e,i),!0)},t.prototype.addToPushed=function(t){if(this.pushedItems.indexOf(t)<0)this.pushedItems.push(t),this.pushedItemsPath.push([{x:t.item.x||0,y:t.item.y||0,cols:t.item.cols||0,rows:t.item.rows||0},{x:t.$item.x,y:t.$item.y,cols:t.$item.cols,rows:t.$item.rows}]);else{var e=this.pushedItems.indexOf(t);this.pushedItemsPath[e].push({x:t.$item.x,y:t.$item.y,cols:t.$item.cols,rows:t.$item.rows})}},t.prototype.removeFromPushed=function(t){t>-1&&(this.pushedItems.splice(t,1),this.pushedItemsPath.splice(t,1))},t.prototype.checkPushedItem=function(t,e){for(var i,s,r,o,h,n=this.pushedItemsPath[e],d=n.length-2;d>-1;d--)i=n[d],s=t.$item.x,r=t.$item.y,o=t.$item.cols,h=t.$item.rows,t.$item.x=i.x,t.$item.y=i.y,t.$item.cols=i.cols,t.$item.rows=i.rows,this.gridster.findItemWithItem(t.$item)?(t.$item.x=s,t.$item.y=r,t.$item.cols=o,t.$item.rows=h):(t.setSize(),n.splice(d+1,n.length-1-d));return n.length<2&&(this.removeFromPushed(e),!0)},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:b}]},t}(),B=function(){function t(t,e,i){this.zone=i,this.gridsterItem=t,this.gridster=e,this.lastMouse={clientX:0,clientY:0},this.itemBackup=[0,0,0,0],this.resizeEventScrollType={w:!1,e:!1,n:!1,s:!1}}return t.prototype.destroy=function(){this.gridster.previewStyle&&this.gridster.previewStyle(),delete this.gridsterItem,delete this.gridster},t.prototype.dragStart=function(t){var e=this;switch(t.which){case 1:break;case 2:case 3:return}this.gridster.options.resizable&&this.gridster.options.resizable.start&&this.gridster.options.resizable.start(this.gridsterItem.item,this.gridsterItem,t),t.stopPropagation(),t.preventDefault(),this.dragFunction=this.dragMove.bind(this),this.dragStopFunction=this.dragStop.bind(this),this.zone.runOutsideAngular(function(){e.mousemove=e.gridsterItem.renderer.listen("document","mousemove",e.dragFunction),e.touchmove=e.gridster.renderer.listen(e.gridster.el,"touchmove",e.dragFunction)}),this.mouseup=this.gridsterItem.renderer.listen("document","mouseup",this.dragStopFunction),this.mouseleave=this.gridsterItem.renderer.listen("document","mouseleave",this.dragStopFunction),this.cancelOnBlur=this.gridsterItem.renderer.listen("window","blur",this.dragStopFunction),this.touchend=this.gridsterItem.renderer.listen("document","touchend",this.dragStopFunction),this.touchcancel=this.gridsterItem.renderer.l