You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -12,91 +12,91 @@ See <a href="https://rawgit.com/ManifestWebDesign/angular-gridster/master/index.
12
12
13
13
Here is an example of the default usage:
14
14
```HTML
15
-
<divgridster>
16
-
<ul>
17
-
<ligridster-item="item"ng-repeat="item in standardItems"></li>
18
-
</ul>
19
-
</div>
15
+
<divgridster>
16
+
<ul>
17
+
<ligridster-item="item"ng-repeat="item in standardItems"></li>
18
+
</ul>
19
+
</div>
20
20
```
21
21
Which expects a scope setup like the following:
22
22
```JavaScript
23
-
// IMPORTANT: Items should be placed in the grid in the order in which they should appear.
24
-
// In most cases the sorting should be by row ASC, col ASC
25
-
26
-
// these map directly to gridsterItem directive options
27
-
$scope.standardItems= [
28
-
{ sizeX:2, sizeY:1, row:0, col:0 },
29
-
{ sizeX:2, sizeY:2, row:0, col:2 },
30
-
{ sizeX:1, sizeY:1, row:0, col:4 },
31
-
{ sizeX:1, sizeY:1, row:0, col:5 },
32
-
{ sizeX:2, sizeY:1, row:1, col:0 },
33
-
{ sizeX:1, sizeY:1, row:1, col:4 },
34
-
{ sizeX:1, sizeY:2, row:1, col:5 },
35
-
{ sizeX:1, sizeY:1, row:2, col:0 },
36
-
{ sizeX:2, sizeY:1, row:2, col:1 },
37
-
{ sizeX:1, sizeY:1, row:2, col:3 },
38
-
{ sizeX:1, sizeY:1, row:2, col:4 }
39
-
];
23
+
// IMPORTANT: Items should be placed in the grid in the order in which they should appear.
24
+
// In most cases the sorting should be by row ASC, col ASC
25
+
26
+
// these map directly to gridsterItem directive options
27
+
$scope.standardItems= [
28
+
{ sizeX:2, sizeY:1, row:0, col:0 },
29
+
{ sizeX:2, sizeY:2, row:0, col:2 },
30
+
{ sizeX:1, sizeY:1, row:0, col:4 },
31
+
{ sizeX:1, sizeY:1, row:0, col:5 },
32
+
{ sizeX:2, sizeY:1, row:1, col:0 },
33
+
{ sizeX:1, sizeY:1, row:1, col:4 },
34
+
{ sizeX:1, sizeY:2, row:1, col:5 },
35
+
{ sizeX:1, sizeY:1, row:2, col:0 },
36
+
{ sizeX:2, sizeY:1, row:2, col:1 },
37
+
{ sizeX:1, sizeY:1, row:2, col:3 },
38
+
{ sizeX:1, sizeY:1, row:2, col:4 }
39
+
];
40
40
```
41
41
Alternatively, you can use the html attributes, similar to the original gridster plugin, but with two-way data binding:
42
42
```HTML
43
-
<divgridster>
44
-
<ul>
45
-
<ligridster-itemrow="item.position[0]"col="item.position[1]"size-x="item.size.x"size-y="item.size.y"ng-repeat="item in customItems"></li>
46
-
</ul>
47
-
</div>
43
+
<divgridster>
44
+
<ul>
45
+
<ligridster-itemrow="item.position[0]"col="item.position[1]"size-x="item.size.x"size-y="item.size.y"ng-repeat="item in customItems"></li>
46
+
</ul>
47
+
</div>
48
48
```
49
49
or:
50
50
```HTML
51
-
<divdata-gridster>
52
-
<ul>
53
-
<lidata-gridster-itemdata-row="item.position[0]"data-col="item.position[1]"data-sizex="item.size.x"data-sizey="item.size.y"ng-repeat="item in customItems"></li>
54
-
</ul>
55
-
</div>
51
+
<divdata-gridster>
52
+
<ul>
53
+
<lidata-gridster-itemdata-row="item.position[0]"data-col="item.position[1]"data-sizex="item.size.x"data-sizey="item.size.y"ng-repeat="item in customItems"></li>
54
+
</ul>
55
+
</div>
56
56
```
57
57
This allows the items to provide their own structure for row, col, and size:
58
58
```JavaScript
59
-
$scope.customItems= [
60
-
{ size: { x:2, y:1 }, position: [0, 0] },
61
-
{ size: { x:2, y:2 }, position: [0, 2] },
62
-
{ size: { x:1, y:1 }, position: [0, 4] },
63
-
{ size: { x:1, y:1 }, position: [0, 5] },
64
-
{ size: { x:2, y:1 }, position: [1, 0] },
65
-
{ size: { x:1, y:1 }, position: [1, 4] },
66
-
{ size: { x:1, y:2 }, position: [1, 5] },
67
-
{ size: { x:1, y:1 }, position: [2, 0] },
68
-
{ size: { x:2, y:1 }, position: [2, 1] },
69
-
{ size: { x:1, y:1 }, position: [2, 3] },
70
-
{ size: { x:1, y:1 }, position: [2, 4] }
71
-
];
59
+
$scope.customItems= [
60
+
{ size: { x:2, y:1 }, position: [0, 0] },
61
+
{ size: { x:2, y:2 }, position: [0, 2] },
62
+
{ size: { x:1, y:1 }, position: [0, 4] },
63
+
{ size: { x:1, y:1 }, position: [0, 5] },
64
+
{ size: { x:2, y:1 }, position: [1, 0] },
65
+
{ size: { x:1, y:1 }, position: [1, 4] },
66
+
{ size: { x:1, y:2 }, position: [1, 5] },
67
+
{ size: { x:1, y:1 }, position: [2, 0] },
68
+
{ size: { x:2, y:1 }, position: [2, 1] },
69
+
{ size: { x:1, y:1 }, position: [2, 3] },
70
+
{ size: { x:1, y:1 }, position: [2, 4] }
71
+
];
72
72
```
73
73
Instead of using attributes for row, col, and size, you can also just use a mapping object for the gridster-item directive:
74
74
```HTML
75
-
<divgridster="gridsterOpts">
76
-
<ul>
77
-
<ligridster-item="customItemMap"ng-repeat="item in customItems"></li>
78
-
</ul>
79
-
</div>
75
+
<divgridster="gridsterOpts">
76
+
<ul>
77
+
<ligridster-item="customItemMap"ng-repeat="item in customItems"></li>
78
+
</ul>
79
+
</div>
80
80
```
81
81
This expects a scope similar to the previous example, but with customItemMap also defined in the scope:
82
82
```JavaScript
83
-
// maps the item from customItems in the scope to the gridsterItem options
84
-
$scope.customItemMap= {
85
-
sizeX:'item.size.x',
86
-
sizeY:'item.size.y',
87
-
row:'item.position[0]',
88
-
col:'item.position[1]',
89
-
minSizeY:'item.minSizeY',
90
-
maxSizeY:'item.maxSizeY'
91
-
};
83
+
// maps the item from customItems in the scope to the gridsterItem options
84
+
$scope.customItemMap= {
85
+
sizeX:'item.size.x',
86
+
sizeY:'item.size.y',
87
+
row:'item.position[0]',
88
+
col:'item.position[1]',
89
+
minSizeY:'item.minSizeY',
90
+
maxSizeY:'item.maxSizeY'
91
+
};
92
92
```
93
93
The gridsterItem directive can be configured like this:
94
94
```HTML
95
-
<divgridster="gridsterOpts">
96
-
<ul>
97
-
<ligridster-item="item"ng-repeat="item in standardItems"></li>
98
-
</ul>
99
-
</div>
95
+
<divgridster="gridsterOpts">
96
+
<ul>
97
+
<ligridster-item="item"ng-repeat="item in standardItems"></li>
98
+
</ul>
99
+
</div>
100
100
```
101
101
102
102
## Configuration
@@ -105,55 +105,72 @@ The gridsterItem directive can be configured like this:
105
105
Simply pass your desired options to the gridster directive
106
106
107
107
```JavaScript
108
-
$scope.gridsterOpts= {
109
-
columns:6, // the width of the grid, in columns
110
-
pushing:true, // whether to push other items out of the way on move or resize
111
-
floating:true, // whether to automatically float items up so they stack (you can temporarily disable if you are adding unsorted items with ng-repeat)
112
-
swapping:false, // whether or not to have items of the same size switch places instead of pushing down if they are the same size
113
-
width:'auto', // can be an integer or 'auto'. 'auto' scales gridster to be the full width of its containing element
114
-
colWidth:'auto', // can be an integer or 'auto'. 'auto' uses the pixel width of the element divided by 'columns'
115
-
rowHeight:'match', // can be an integer or 'match'. Match uses the colWidth, giving you square widgets.
116
-
margins: [10, 10], // the pixel distance between each widget
117
-
outerMargin:true, // whether margins apply to outer edges of the grid
118
-
isMobile:false, // stacks the grid items if true
119
-
mobileBreakPoint:600, // if the screen is not wider that this, remove the grid layout and stack the items
120
-
mobileModeEnabled:true, // whether or not to toggle mobile mode when screen width is less than mobileBreakPoint
121
-
minColumns:1, // the minimum columns the grid must have
122
-
minRows:2, // the minimum height of the grid, in rows
123
-
maxRows:100,
124
-
defaultSizeX:2, // the default width of a gridster item, if not specifed
125
-
defaultSizeY:1, // the default height of a gridster item, if not specified
0 commit comments