Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6ec4430
add windows demo building instructions
Blackbaud-StewartStephens Apr 19, 2018
ed782a2
variable height basics
Blackbaud-StewartStephens Apr 19, 2018
6007a4d
correct initial variable height stuff
Blackbaud-StewartStephens Apr 19, 2018
f47fb8d
variable height modifying via row pixel height poc
Blackbaud-StewartStephens Apr 20, 2018
bdc2a7f
Merge branch 'master' of https://github.com/swiety85/angular2gridster
Blackbaud-StewartStephens Jul 5, 2018
1e2ea6f
Merge branch 'master' into ft-923758-variable-height
Blackbaud-StewartStephens Jul 5, 2018
d8a7483
get demo working
Blackbaud-StewartStephens Jul 5, 2018
0e61a84
update readme
Blackbaud-StewartStephens Jul 5, 2018
9fcbcca
kind of fix demo
Blackbaud-StewartStephens Jul 5, 2018
1fada20
sort of fix variable height
Blackbaud-StewartStephens Jul 9, 2018
1246978
fix up demo some more
Blackbaud-StewartStephens Jul 10, 2018
550045f
fix mutation observer
Blackbaud-StewartStephens Jul 10, 2018
196b6d9
sort of fix the grid lines
Blackbaud-StewartStephens Jul 11, 2018
5507dc9
make row stretching the only variable height behavior
Blackbaud-StewartStephens Jul 23, 2018
22d8d5c
add remove content button to demo
Blackbaud-StewartStephens Jul 23, 2018
f62873b
remove console logs, refresh grid lines when resizing item
Blackbaud-StewartStephens Jul 23, 2018
ab9894d
resize all items when resizing variable height item
Blackbaud-StewartStephens Jul 23, 2018
b329a75
fix a lot of linting errors
Blackbaud-StewartStephens Aug 10, 2018
73384a4
try downgrading angular
Blackbaud-StewartStephens Aug 23, 2018
8a55e50
change some dependency versions
Blackbaud-StewartStephens Aug 24, 2018
112d707
remove 'compatible' operator from angular dependencies
Blackbaud-StewartStephens Aug 24, 2018
eaa2ba1
fix style issue for non-variable height tiles
Blackbaud-StewartStephens Aug 29, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ npm-debug.log
yarn-error.log
testem.log
/typings
src/app/angular2gridster

# System Files
.DS_Store
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ npm i
npm start
```

Windows:
In CMD run `MKLINK /D .\src\app\angular2gridster D:\your\absolute\path\to\angular2gridster\projects\angular2gridster\src\lib` (make sure the second path is the correct absolute for your environment).

Then run the following:
```shell
npm install
ng serve
```

Go to: http://localhost:4200/

## Compilation problems
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@
},
"homepage": "https://github.com/swiety85/angular2gridster#readme",
"dependencies": {
"@angular/common": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/animations": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@angular/common": "4.3.6",
"@angular/core": "4.3.6",
"@angular/compiler": "4.3.6",
"@angular/animations": "4.3.6",
"@angular/forms": "4.3.6",
"@angular/http": "4.3.6",
"@angular/platform-browser": "4.3.6",
"@angular/platform-browser-dynamic": "4.3.6",
"@angular/router": "4.3.6",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"rxjs": "^5.4.3",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.5",
"@angular-devkit/build-ng-packagr": "~0.6.5",
"@angular/cli": "~6.0.7",
"@angular/compiler-cli": "^6.0.3",
"@angular/language-service": "^6.0.3",
"@angular/cli": "~1.7.4",
"@angular/compiler-cli": "4.3.6",
"@angular/language-service": "4.3.6",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
Expand Down
10 changes: 5 additions & 5 deletions projects/angular2gridster/src/lib/GridsterOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Observable, of, fromEvent, pipe, merge } from 'rxjs';
import { Observable } from 'rxjs';
import { debounceTime, map, distinctUntilChanged } from 'rxjs/operators';

import { IGridsterOptions } from './IGridsterOptions';
Expand Down Expand Up @@ -35,7 +35,7 @@ export class GridsterOptions {
responsiveOptions: Array<IGridsterOptions> = [];
basicOptions: IGridsterOptions;

breakpointsMap = {
breakpointsMap: {[index: string]: number} = {
sm: 576, // Small devices
md: 768, // Medium devices
lg: 992, // Large devices
Expand All @@ -47,9 +47,9 @@ export class GridsterOptions {

this.responsiveOptions = this.extendResponsiveOptions(config.responsiveOptions || []);

this.change = merge(
of(this.getOptionsByWidth(document.documentElement.clientWidth)),
fromEvent(window, 'resize').pipe(
this.change = Observable.merge(
Observable.of(this.getOptionsByWidth(document.documentElement.clientWidth)),
Observable.fromEvent(window, 'resize').pipe(
debounceTime(config.responsiveDebounce || 0),
map((event: Event) => this.getOptionsByWidth(document.documentElement.clientWidth))
)
Expand Down
86 changes: 61 additions & 25 deletions projects/angular2gridster/src/lib/gridList/GridListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export class GridListItem {
get h () {
const item = this.getItem();
const breakpoint = item.gridster ? item.gridster.options.breakpoint : null;

return this.getValueH(breakpoint);
}
set h (value: number) {
Expand Down Expand Up @@ -127,6 +126,18 @@ export class GridListItem {
return item.positionY;
}

get variableHeight(): boolean {
return this.getItem().variableHeight;
}

get contentHeight(): number {
const contentHeight = this.itemComponent.contentWrapper.nativeElement.offsetheight || 0;
const childHeight = this.$element.firstChild.offsetHeight || 0;
return Math.max(contentHeight, childHeight);
}

constructor () {}

public setFromGridsterItem (item: GridsterItemComponent): GridListItem {
if (this.isItemSet()) {
throw new Error('GridListItem is already set.');
Expand Down Expand Up @@ -166,7 +177,7 @@ export class GridListItem {
});
}

public copyForBreakpoint(breakpoint?) {
public copyForBreakpoint(breakpoint?: string) {
const itemCopy = new GridListItem();

return itemCopy.setFromObjectLiteral({
Expand All @@ -181,83 +192,83 @@ export class GridListItem {
});
}

public getValueX(breakpoint?) {
public getValueX(breakpoint?: string) {
const item = this.getItem();

return item[this.getXProperty(breakpoint)];
}

public getValueY(breakpoint?) {
public getValueY(breakpoint?: string) {
const item = this.getItem();

return item[this.getYProperty(breakpoint)];
}

public getValueW(breakpoint?) {
public getValueW(breakpoint?: string) {
const item = this.getItem();

return item[this.getWProperty(breakpoint)] || 1;
}

public getValueH(breakpoint?) {
public getValueH(breakpoint?: string) {
const item = this.getItem();

return item[this.getHProperty(breakpoint)] || 1;
}

public setValueX(value: number, breakpoint?) {
public setValueX(value: number, breakpoint?: string) {
const item = this.getItem();

item[this.getXProperty(breakpoint)] = value;
}

public setValueY(value: number, breakpoint?) {
public setValueY(value: number, breakpoint?: string) {
const item = this.getItem();

item[this.getYProperty(breakpoint)] = value;
}

public setValueW(value: number, breakpoint?) {
public setValueW(value: number, breakpoint?: string) {
const item = this.getItem();

item[this.getWProperty(breakpoint)] = value;
}

public setValueH(value: number, breakpoint?) {
public setValueH(value: number, breakpoint?: string) {
const item = this.getItem();

item[this.getHProperty(breakpoint)] = value;
}

public triggerChangeX(breakpoint?) {
public triggerChangeX(breakpoint?: string) {
const item = this.itemComponent;
if (item) {
item[this.getXProperty(breakpoint) + 'Change'].emit(this.getValueX(breakpoint));
(<any>item)[this.getXProperty(breakpoint) + 'Change'].emit(this.getValueX(breakpoint));
}
}

public triggerChangeY(breakpoint?) {
public triggerChangeY(breakpoint?: string) {
const item = this.itemComponent;
if (item) {
item[this.getYProperty(breakpoint) + 'Change'].emit(this.getValueY(breakpoint));
(<any>item)[this.getYProperty(breakpoint) + 'Change'].emit(this.getValueY(breakpoint));
}
}

public triggerChangeW(breakpoint?) {
public triggerChangeW(breakpoint?: string) {
const item = this.itemComponent;
if (item) {
item[this.getWProperty(breakpoint) + 'Change'].emit(this.getValueW(breakpoint));
(<any>item)[this.getWProperty(breakpoint) + 'Change'].emit(this.getValueW(breakpoint));
}
}

public triggerChangeH(breakpoint?) {
public triggerChangeH(breakpoint?: string) {
const item = this.itemComponent;
if (item) {
item[this.getHProperty(breakpoint) + 'Change'].emit(this.getValueH(breakpoint));
(<any>item)[this.getHProperty(breakpoint) + 'Change'].emit(this.getValueH(breakpoint));
}
}

public hasPositions(breakpoint?) {
public hasPositions(breakpoint?: string) {
const x = this.getValueX(breakpoint);
const y = this.getValueY(breakpoint);

Expand All @@ -278,9 +289,18 @@ export class GridListItem {
}
gridster = gridster || this.itemComponent.gridster;

let top;
if (gridster.gridList) {
const rowHeights = gridster.getRowHeights();
const rowTops = gridster.getRowTops(rowHeights);
top = rowTops[this.y];
} else {
top = this.y * gridster.cellHeight;
}

return {
left: this.x * gridster.cellWidth,
top: this.y * gridster.cellHeight
top: top
};
}

Expand All @@ -297,8 +317,14 @@ export class GridListItem {
}
gridster = gridster || this.itemComponent.gridster;

let width = this.getValueW(gridster.options.breakpoint);
let height = this.getValueH(gridster.options.breakpoint);
let rowHeights, rowTops;
if (gridster.gridList) {
rowHeights = gridster.getRowHeights();
rowTops = gridster.getRowTops(rowHeights);
}

let width = this.w;
let height = this.h;

if (gridster.options.direction === 'vertical') {
width = Math.min(width, gridster.options.lanes);
Expand All @@ -307,9 +333,19 @@ export class GridListItem {
height = Math.min(height, gridster.options.lanes);
}

let pixelHeight;
if (rowHeights) {
pixelHeight = 0;
for (let i = this.y; i < this.y + height; i++) {
pixelHeight += rowHeights[i];
}
} else {
pixelHeight = height * gridster.cellHeight;
}

return {
width: width * gridster.cellWidth,
height: height * gridster.cellHeight
height: pixelHeight
};
}

Expand All @@ -333,7 +369,7 @@ export class GridListItem {

private getWProperty(breakpoint?: string) {
if (this.itemPrototype) {
return this.itemPrototype[GridListItem.W_PROPERTY_MAP[breakpoint]] ?
return (<any>this.itemPrototype)[GridListItem.W_PROPERTY_MAP[breakpoint]] ?
GridListItem.W_PROPERTY_MAP[breakpoint] : 'w';
}

Expand All @@ -349,7 +385,7 @@ export class GridListItem {

private getHProperty(breakpoint?: string) {
if (this.itemPrototype) {
return this.itemPrototype[GridListItem.H_PROPERTY_MAP[breakpoint]] ?
return (<any>this.itemPrototype)[GridListItem.H_PROPERTY_MAP[breakpoint]] ?
GridListItem.H_PROPERTY_MAP[breakpoint] : 'w';
}

Expand Down
Loading