Icard/angular-clarity-master(work.../node_modules/angular-gridster2/esm2022/lib/gridsterCompact.service.mjs

126 lines
20 KiB
JavaScript

import { CompactType } from './gridsterConfig.interface';
export class GridsterCompact {
constructor(gridster) {
this.gridster = gridster;
}
destroy() {
this.gridster = null;
}
checkCompact() {
if (this.gridster.$options.compactType !== CompactType.None) {
if (this.gridster.$options.compactType === CompactType.CompactUp) {
this.checkCompactMovement('y', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
this.checkCompactMovement('x', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
this.checkCompactMovement('y', -1);
this.checkCompactMovement('x', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
this.checkCompactMovement('x', -1);
this.checkCompactMovement('y', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactRight) {
this.checkCompactMovement('x', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
this.checkCompactMovement('y', -1);
this.checkCompactMovement('x', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactRightAndUp) {
this.checkCompactMovement('x', 1);
this.checkCompactMovement('y', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactDown) {
this.checkCompactMovement('y', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactDownAndLeft) {
this.checkCompactMovement('y', 1);
this.checkCompactMovement('x', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactDownAndRight) {
this.checkCompactMovement('y', 1);
this.checkCompactMovement('x', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactLeftAndDown) {
this.checkCompactMovement('x', -1);
this.checkCompactMovement('y', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactRightAndDown) {
this.checkCompactMovement('x', 1);
this.checkCompactMovement('y', 1);
}
}
}
checkCompactItem(item) {
if (this.gridster.$options.compactType !== CompactType.None) {
if (this.gridster.$options.compactType === CompactType.CompactUp) {
this.moveTillCollision(item, 'y', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
this.moveTillCollision(item, 'x', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
this.moveTillCollision(item, 'y', -1);
this.moveTillCollision(item, 'x', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
this.moveTillCollision(item, 'x', -1);
this.moveTillCollision(item, 'y', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
this.moveTillCollision(item, 'y', -1);
this.moveTillCollision(item, 'x', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactDown) {
this.moveTillCollision(item, 'y', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactDownAndLeft) {
this.moveTillCollision(item, 'y', 1);
this.moveTillCollision(item, 'x', -1);
}
else if (this.gridster.$options.compactType === CompactType.CompactLeftAndDown) {
this.moveTillCollision(item, 'x', -1);
this.moveTillCollision(item, 'y', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactDownAndRight) {
this.moveTillCollision(item, 'y', 1);
this.moveTillCollision(item, 'x', 1);
}
else if (this.gridster.$options.compactType === CompactType.CompactRightAndDown) {
this.moveTillCollision(item, 'x', 1);
this.moveTillCollision(item, 'y', 1);
}
}
}
checkCompactMovement(direction, delta) {
let widgetMoved = false;
this.gridster.grid.forEach((widget) => {
if (widget.$item.compactEnabled !== false) {
const moved = this.moveTillCollision(widget.$item, direction, delta);
if (moved) {
widgetMoved = true;
widget.item[direction] = widget.$item[direction];
widget.itemChanged();
}
}
});
if (widgetMoved) {
this.checkCompact();
}
}
moveTillCollision(item, direction, delta) {
item[direction] += delta;
if (this.gridster.checkCollision(item)) {
item[direction] -= delta;
return false;
}
else {
this.moveTillCollision(item, direction, delta);
return true;
}
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZHN0ZXJDb21wYWN0LnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi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