Skip to content

Commit

Permalink
Added CompactType.CompactDown with variants (#736)
Browse files Browse the repository at this point in the history
* feat: add compact down variants

* chore: update demo to include compact down variants
  • Loading branch information
bohoffi authored May 12, 2021
1 parent 676e740 commit 0c7eafe
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
28 changes: 28 additions & 0 deletions projects/angular-gridster2/src/lib/gridsterCompact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ export class GridsterCompact {
} 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);
}
}
}
Expand All @@ -51,6 +65,20 @@ export class GridsterCompact {
} 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);
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion projects/angular-gridster2/src/lib/gridsterConfig.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ export type compactTypes =
| 'compactLeft&Up'
| 'compactRight'
| 'compactUp&Right'
| 'compactRight&Up';
| 'compactRight&Up'
| 'compactDown'
| 'compactDown&Left'
| 'compactLeft&Down'
| 'compactDown&Right'
| 'compactRight&Down';

export enum GridType {
Fit = 'fit',
Expand All @@ -37,6 +42,11 @@ export enum CompactType {
CompactRight = 'compactRight',
CompactUpAndRight = 'compactUp&Right',
CompactRightAndUp = 'compactRight&Up',
CompactDown = 'compactDown',
CompactDownAndLeft = 'compactDown&Left',
CompactLeftAndDown = 'compactLeft&Down',
CompactDownAndRight = 'compactDown&Right',
CompactRightAndDown = 'compactRight&Down'
}

export enum DirTypes {
Expand Down
5 changes: 5 additions & 0 deletions src/app/sections/compact/compact.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<mat-option value="compactRight">Compact Right</mat-option>
<mat-option value="compactUp&Right">Compact Up & Right</mat-option>
<mat-option value="compactRight&Up">Compact Right & Up</mat-option>
<mat-option value="compactDown">Compact Down</mat-option>
<mat-option value="compactDown&Left">Compact Down & Left</mat-option>
<mat-option value="compactLeft&Down">Compact Left & Down</mat-option>
<mat-option value="compactDown&Right">Compact Down & Right</mat-option>
<mat-option value="compactRight&Down">Compact Right & Down</mat-option>
</mat-select>
</mat-form-field>
<button mat-mini-fab (click)="addItem()" class="add-button cols-2">
Expand Down
1 change: 1 addition & 0 deletions src/app/sections/compact/compact.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class CompactComponent implements OnInit {
gridType: GridType.Fit,
compactType: CompactType.None,
maxCols: 10,
maxRows: 10,
pushItems: true,
draggable: {
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion src/assets/compact.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Option | Description | Type | Default | Options
------------ | ------------- | ------------- | ------------- | -------------
compactType | compact items | String | 'none' | 'none', 'compactUp', 'compactLeft', 'compactUp&Left', 'compactLeft&Up', 'compactRight', 'compactUp&Right', 'compactRight&Up'
compactType | compact items | String | 'none' | 'none', 'compactUp', 'compactLeft', 'compactUp&Left', 'compactLeft&Up', 'compactRight', 'compactUp&Right', 'compactRight&Up', 'compactDown', 'compactDown&Left', 'compactLeft&Down', 'compactDown&Right', 'compactRight&Down'

0 comments on commit 0c7eafe

Please sign in to comment.