angular-gridster2
Advanced tools
Comparing version 2.10.1 to 2.10.2
@@ -39,2 +39,3 @@ import { OnInit, ElementRef, OnDestroy, Renderer2, DoCheck } from '@angular/core'; | ||
checkCollision(itemComponent: GridsterItemComponent, ignoreItem?: GridsterItemComponent): GridsterItemComponent | boolean; | ||
checkGridCollision(itemComponent: GridsterItemComponent): boolean; | ||
findItemWithItem(itemComponent: GridsterItemComponent, ignoreItem?: GridsterItemComponent): GridsterItemComponent; | ||
@@ -41,0 +42,0 @@ autoPositionItem(itemComponent: GridsterItemComponent): void; |
@@ -208,2 +208,8 @@ "use strict"; | ||
GridsterComponent.prototype.checkCollision = function (itemComponent, ignoreItem) { | ||
if (this.checkGridCollision(itemComponent)) { | ||
return true; | ||
} | ||
return this.findItemWithItem(itemComponent, ignoreItem); | ||
}; | ||
GridsterComponent.prototype.checkGridCollision = function (itemComponent) { | ||
var noNegativePosition = itemComponent.$item.y > -1 && itemComponent.$item.x > -1; | ||
@@ -218,6 +224,3 @@ var maxGridCols = itemComponent.$item.cols + itemComponent.$item.x <= this.$options.maxCols; | ||
var inRowsLimits = itemComponent.$item.rows <= maxItemRows && itemComponent.$item.rows >= minItemRows; | ||
if (!(noNegativePosition && maxGridCols && maxGridRows && inColsLimits && inRowsLimits)) { | ||
return true; | ||
} | ||
return this.findItemWithItem(itemComponent, ignoreItem); | ||
return !(noNegativePosition && maxGridCols && maxGridRows && inColsLimits && inRowsLimits); | ||
}; | ||
@@ -276,6 +279,6 @@ GridsterComponent.prototype.findItemWithItem = function (itemComponent, ignoreItem) { | ||
GridsterComponent.prototype.pixelsToPositionX = function (x, roundingMethod) { | ||
return roundingMethod(Math.abs(x) / this.curColWidth); | ||
return roundingMethod(x / this.curColWidth); | ||
}; | ||
GridsterComponent.prototype.pixelsToPositionY = function (y, roundingMethod) { | ||
return roundingMethod(Math.abs(y) / this.curRowHeight); | ||
return roundingMethod(y / this.curRowHeight); | ||
}; | ||
@@ -282,0 +285,0 @@ GridsterComponent.prototype.positionXToPixels = function (x) { |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"GridsterComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"gridster","template":"<gridster-grid class=\"gridster-grid\"></gridster-grid> <ng-content></ng-content> <gridster-preview class=\"gridster-preview\"></gridster-preview>","styles":[":host { position: relative; display: flex; overflow: auto; flex: 1 auto; background: grey; width: 100%; height: 100%; } :host(.fit) { overflow-x: hidden; overflow-y: hidden; } :host(.scrollVertical) { overflow-x: hidden; overflow-y: auto; } :host(.scrollHorizontal) { overflow-x: auto; overflow-y: hidden; } :host(.fixed) { overflow: auto; } :host(.mobile) { overflow-x: hidden; overflow-y: auto; display: block; } :host(.mobile) /deep/ gridster-item { position: relative; }"]}]}],"members":{"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer2"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"optionsChanged":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onResize":[{"__symbolic":"method"}],"checkIfToResize":[{"__symbolic":"method"}],"setGridSize":[{"__symbolic":"method"}],"setGridDimensions":[{"__symbolic":"method"}],"calculateLayout":[{"__symbolic":"method"}],"addItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"checkCollision":[{"__symbolic":"method"}],"findItemWithItem":[{"__symbolic":"method"}],"autoPositionItem":[{"__symbolic":"method"}],"pixelsToPosition":[{"__symbolic":"method"}],"pixelsToPositionX":[{"__symbolic":"method"}],"pixelsToPositionY":[{"__symbolic":"method"}],"positionXToPixels":[{"__symbolic":"method"}],"positionYToPixels":[{"__symbolic":"method"}],"checkCompactUp":[{"__symbolic":"method"}],"moveUpTillCollision":[{"__symbolic":"method"}],"checkCompactLeft":[{"__symbolic":"method"}],"moveLeftTillCollision":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"GridsterComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"gridster","template":"<gridster-grid class=\"gridster-grid\"></gridster-grid> <ng-content></ng-content> <gridster-preview class=\"gridster-preview\"></gridster-preview>","styles":[":host { position: relative; display: flex; overflow: auto; flex: 1 auto; background: grey; width: 100%; height: 100%; } :host(.fit) { overflow-x: hidden; overflow-y: hidden; } :host(.scrollVertical) { overflow-x: hidden; overflow-y: auto; } :host(.scrollHorizontal) { overflow-x: auto; overflow-y: hidden; } :host(.fixed) { overflow: auto; } :host(.mobile) { overflow-x: hidden; overflow-y: auto; display: block; } :host(.mobile) /deep/ gridster-item { position: relative; }"]}]}],"members":{"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer2"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"optionsChanged":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onResize":[{"__symbolic":"method"}],"checkIfToResize":[{"__symbolic":"method"}],"setGridSize":[{"__symbolic":"method"}],"setGridDimensions":[{"__symbolic":"method"}],"calculateLayout":[{"__symbolic":"method"}],"addItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"checkCollision":[{"__symbolic":"method"}],"findItemWithItem":[{"__symbolic":"method"}],"autoPositionItem":[{"__symbolic":"method"}],"pixelsToPosition":[{"__symbolic":"method"}],"pixelsToPositionX":[{"__symbolic":"method"}],"pixelsToPositionY":[{"__symbolic":"method"}],"positionXToPixels":[{"__symbolic":"method"}],"positionYToPixels":[{"__symbolic":"method"}],"checkCompactUp":[{"__symbolic":"method"}],"moveUpTillCollision":[{"__symbolic":"method"}],"checkCompactLeft":[{"__symbolic":"method"}],"moveLeftTillCollision":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"GridsterComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"gridster","template":"<gridster-grid class=\"gridster-grid\"></gridster-grid> <ng-content></ng-content> <gridster-preview class=\"gridster-preview\"></gridster-preview>","styles":[":host { position: relative; display: flex; overflow: auto; flex: 1 auto; background: grey; width: 100%; height: 100%; } :host(.fit) { overflow-x: hidden; overflow-y: hidden; } :host(.scrollVertical) { overflow-x: hidden; overflow-y: auto; } :host(.scrollHorizontal) { overflow-x: auto; overflow-y: hidden; } :host(.fixed) { overflow: auto; } :host(.mobile) { overflow-x: hidden; overflow-y: auto; display: block; } :host(.mobile) /deep/ gridster-item { position: relative; }"]}]}],"members":{"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer2"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"optionsChanged":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onResize":[{"__symbolic":"method"}],"checkIfToResize":[{"__symbolic":"method"}],"setGridSize":[{"__symbolic":"method"}],"setGridDimensions":[{"__symbolic":"method"}],"calculateLayout":[{"__symbolic":"method"}],"addItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"checkCollision":[{"__symbolic":"method"}],"checkGridCollision":[{"__symbolic":"method"}],"findItemWithItem":[{"__symbolic":"method"}],"autoPositionItem":[{"__symbolic":"method"}],"pixelsToPosition":[{"__symbolic":"method"}],"pixelsToPositionX":[{"__symbolic":"method"}],"pixelsToPositionY":[{"__symbolic":"method"}],"positionXToPixels":[{"__symbolic":"method"}],"positionYToPixels":[{"__symbolic":"method"}],"checkCompactUp":[{"__symbolic":"method"}],"moveUpTillCollision":[{"__symbolic":"method"}],"checkCompactLeft":[{"__symbolic":"method"}],"moveLeftTillCollision":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"GridsterComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"gridster","template":"<gridster-grid class=\"gridster-grid\"></gridster-grid> <ng-content></ng-content> <gridster-preview class=\"gridster-preview\"></gridster-preview>","styles":[":host { position: relative; display: flex; overflow: auto; flex: 1 auto; background: grey; width: 100%; height: 100%; } :host(.fit) { overflow-x: hidden; overflow-y: hidden; } :host(.scrollVertical) { overflow-x: hidden; overflow-y: auto; } :host(.scrollHorizontal) { overflow-x: auto; overflow-y: hidden; } :host(.fixed) { overflow: auto; } :host(.mobile) { overflow-x: hidden; overflow-y: auto; display: block; } :host(.mobile) /deep/ gridster-item { position: relative; }"]}]}],"members":{"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer2"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"optionsChanged":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onResize":[{"__symbolic":"method"}],"checkIfToResize":[{"__symbolic":"method"}],"setGridSize":[{"__symbolic":"method"}],"setGridDimensions":[{"__symbolic":"method"}],"calculateLayout":[{"__symbolic":"method"}],"addItem":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"checkCollision":[{"__symbolic":"method"}],"checkGridCollision":[{"__symbolic":"method"}],"findItemWithItem":[{"__symbolic":"method"}],"autoPositionItem":[{"__symbolic":"method"}],"pixelsToPosition":[{"__symbolic":"method"}],"pixelsToPositionX":[{"__symbolic":"method"}],"pixelsToPositionY":[{"__symbolic":"method"}],"positionXToPixels":[{"__symbolic":"method"}],"positionYToPixels":[{"__symbolic":"method"}],"checkCompactUp":[{"__symbolic":"method"}],"moveUpTillCollision":[{"__symbolic":"method"}],"checkCompactLeft":[{"__symbolic":"method"}],"moveLeftTillCollision":[{"__symbolic":"method"}]}}}}] |
@@ -132,6 +132,15 @@ "use strict"; | ||
GridsterDraggable.prototype.calculateItemPosition = function () { | ||
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.gridsterItem.$item.y = this.positionY; | ||
if (this.gridster.checkGridCollision(this.gridsterItem)) { | ||
this.gridsterItem.$item.x = this.positionXBackup; | ||
this.gridsterItem.$item.y = this.positionYBackup; | ||
return; | ||
} | ||
this.gridsterItem.renderer.setStyle(this.gridsterItem.el, 'left', this.left + 'px'); | ||
this.gridsterItem.renderer.setStyle(this.gridsterItem.el, 'top', this.top + 'px'); | ||
this.positionX = this.gridster.pixelsToPositionX(this.left, Math.round); | ||
this.positionY = this.gridster.pixelsToPositionY(this.top, Math.round); | ||
if (this.positionX !== this.gridsterItem.$item.x || this.positionY !== this.gridsterItem.$item.y) { | ||
@@ -138,0 +147,0 @@ this.positionXBackup = this.gridsterItem.$item.x; |
@@ -29,2 +29,4 @@ "use strict"; | ||
this.swapedItem.setSize(true); | ||
this.gridsterItem.$item.x = this.gridsterItem.item.x; | ||
this.gridsterItem.$item.y = this.gridsterItem.item.y; | ||
this.swapedItem = undefined; | ||
@@ -31,0 +33,0 @@ } |
{ | ||
"name": "angular-gridster2", | ||
"version": "2.10.1", | ||
"version": "2.10.2", | ||
"license": "MIT", | ||
@@ -47,7 +47,6 @@ "main": "dist/index.js", | ||
], | ||
"dependencies": { | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@angular/animations": "4.1.3", | ||
"@angular/cli": "1.0.4", | ||
"@angular/cli": "1.0.6", | ||
"@angular/common": "4.1.3", | ||
@@ -60,3 +59,3 @@ "@angular/compiler": "4.1.3", | ||
"@angular/language-service": "4.1.3", | ||
"@angular/material": "2.0.0-beta.5", | ||
"@angular/material": "2.0.0-beta.6", | ||
"@angular/platform-browser": "4.1.3", | ||
@@ -67,3 +66,3 @@ "@angular/platform-browser-dynamic": "4.1.3", | ||
"@types/jasmine": "2.5.47", | ||
"@types/node": "7.0.21", | ||
"@types/node": "7.0.22", | ||
"codelyzer": "3.0.1", | ||
@@ -80,7 +79,7 @@ "core-js": "2.4.1", | ||
"karma-cli": "1.0.1", | ||
"karma-coverage-istanbul-reporter": "1.2.1", | ||
"karma-coverage-istanbul-reporter": "1.3.0", | ||
"karma-jasmine": "1.1.0", | ||
"karma-jasmine-html-reporter": "0.2.2", | ||
"protractor": "5.1.2", | ||
"systemjs": "0.20.12", | ||
"systemjs": "0.20.13", | ||
"rxjs": "5.4.0", | ||
@@ -90,6 +89,6 @@ "ts-helpers": "1.1.2", | ||
"tslib": "1.7.1", | ||
"tslint": "5.2.0", | ||
"typescript": "2.3.2", | ||
"tslint": "5.3.2", | ||
"typescript": "2.3.4", | ||
"zone.js": "0.8.11" | ||
} | ||
} |
@@ -9,5 +9,7 @@ angular-gridster2 | ||
### Angular2 implementation of angular-gridster [Demo](http://tiberiuzuld.github.io/angular-gridster2/angular) | ||
### Angular implementation of angular-gridster [Demo](http://tiberiuzuld.github.io/angular-gridster2/angular) | ||
### AngularJS 1.x library is [here](https://github.com/tiberiuzuld/angular-gridster2/tree/1.x) | ||
### Angular 4.x library is [master branch](https://github.com/tiberiuzuld/angular-gridster2/tree/master) | ||
### Angular 2.x library is [2.4.x branch](https://github.com/tiberiuzuld/angular-gridster2/tree/2.4.x) | ||
### AngularJS 1.x library is [1.x branch](https://github.com/tiberiuzuld/angular-gridster2/tree/1.x) | ||
@@ -14,0 +16,0 @@ ## Install |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202481
1946
248