Skip to content

Commit cd48e44

Browse files
committed
Merge branch 'master' of github.com:ManifestWebDesign/angular-gridster
2 parents 3207124 + 7249674 commit cd48e44

1 file changed

Lines changed: 95 additions & 19 deletions

File tree

README.md

Lines changed: 95 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ angular-gridster
44

55
An implementation of gridster-like widgets for Angular JS. This is not a wrapper on the original gridster jQuery plugin (http://gridster.net/). It is instead completely rewritten as Angular directives. Rewriting allowed for some additional features and better use of Angular data binding. Even more importantly, the original plugin had unpredictable behavior and crashed when wrapped with an Angular directive in my initial tests.
66

7-
##Demo
7+
## Demo
88

99
See <a href="https://rawgit.com/ManifestWebDesign/angular-gridster/master/index.html">Live Demo</a>
1010

11-
##Usage
11+
## Usage
1212

1313
Here is an example of the default usage:
1414
```HTML
@@ -154,24 +154,100 @@ You can also override the default configuration site wide by modifying the ```gr
154154
}]);
155155
```
156156

157-
##Watching gridster element size changes
157+
## Gridster Events
158158

159-
When the window or gridster element are resized, all the gridster item elements are resized accordingly and this event is broadcast:
159+
#### gridster-mobile-changed
160+
When the gridster goes in or out of mobile mode, a 'gridster-mobile-changed' event is broadcast on rootScope:
160161

161-
```JavaScript
162-
$scope.$broadcast('gridster-resized', [width, height]);
162+
```js
163+
scope.$on('gridster-mobile-changed', function(gridster) {
164+
})
163165
```
164166

165-
It can be handled like this:
167+
#### gridster-draggable-changed
168+
When the gridster draggable properties change, a 'gridster-draggable-changed' event is broadcast on rootScope:
166169

167-
```JavaScript
168-
$scope.$on('gridster-resized', function(event, newSizes){
169-
var newWidth = newSizes[0];
170-
var newHeight = newSizes[1];
171-
});
170+
```js
171+
scope.$on('gridster-draggable-changed', function(gridster) {
172+
})
173+
```
174+
175+
#### gridster-resizable-changed
176+
When the gridster resizable properties change, a 'gridster-resizable-changed' event is broadcast on rootScope:
177+
178+
```js
179+
scope.$on('gridster-resizable-changed', function(gridster) {
180+
})
181+
```
182+
183+
#### gridster-resized
184+
When the gridster element's size changes, a 'gridster-resized' event is broadcast on rootScope:
185+
186+
```js
187+
scope.$on('gridster-resized', function(sizes, gridster) {
188+
// sizes[0] = width
189+
// sizes[1] = height
190+
// gridster.
191+
})
192+
```
193+
194+
## Gridster Item Events
195+
196+
#### gridster-item-transition-end
197+
Gridster items have CSS transitions by default. Gridster items listen for css transition-end across different browsers and broadcast the event 'gridster-item-transition-end'. You can listen for it like this from within the gridster-item directive:
198+
199+
```js
200+
scope.$on('gridster-item-transition-end', function(item) {
201+
// item.$element
202+
// item.gridster
203+
// item.row
204+
// item.col
205+
// item.sizeX
206+
// item.sizeY
207+
// item.minSizeX
208+
// item.minSizeY
209+
// item.maxSizeX
210+
// item.maxSizeY
211+
})
212+
```
213+
214+
#### gridster-item-initialized
215+
After a gridster item's controller has finished with setup, it broadcasts an event 'gridster-item-initialized' on its own scope. You can listen for it like this from within the gridster-item directive:
216+
217+
```js
218+
scope.$on('gridster-item-initialized', function(item) {
219+
// item.$element
220+
// item.gridster
221+
// item.row
222+
// item.col
223+
// item.sizeX
224+
// item.sizeY
225+
// item.minSizeX
226+
// item.minSizeY
227+
// item.maxSizeX
228+
// item.maxSizeY
229+
})
230+
```
231+
232+
#### gridster-item-resized
233+
After a gridster item's size changes (rows or columns), it broadcasts an event 'gridster-item-resized' on its own scope. You can listen for it like this from within the gridster-item directive:
234+
235+
```js
236+
scope.$on('gridster-item-resized', function(item) {
237+
// item.$element
238+
// item.gridster
239+
// item.row
240+
// item.col
241+
// item.sizeX
242+
// item.sizeY
243+
// item.minSizeX
244+
// item.minSizeY
245+
// item.maxSizeX
246+
// item.maxSizeY
247+
})
172248
```
173249

174-
##Watching item changes of size and position
250+
## Watching item changes of size and position
175251

176252
The typical Angular way would be to do a $scope.$watch on your item or items in the scope. Example:
177253

@@ -203,7 +279,7 @@ $scope.$watch('items[0].sizeX', function(){
203279
The third argument, true, is to make the watch based on the value of the object, rather than just matching the reference to the object.
204280

205281

206-
##Note
282+
## Note
207283
This directive/plugin does not generate style tags, like the jQuery plugin. It also uses standard camelCase for variables and object properties, while the original plugin used lower\_case\_with_underscores. These options have not and may never be implemented:
208284

209285
* widget_class - not necessary since directives already whatever classes and attributes you want to add
@@ -227,7 +303,7 @@ This directive/plugin does not generate style tags, like the jQuery plugin. It
227303
* collision.on_overlap
228304
* collision.on\_overlap\_stop
229305

230-
##Installation
306+
## Installation
231307

232308
```bash
233309
bower install angular-gridster
@@ -242,18 +318,18 @@ Then, import the following in your HTML alongside `jQuery` and `angular`:
242318

243319
`jquery.resize` is a jQuery plugin needed to check for changes in the gridster size.
244320

245-
##Contributing
321+
## Contributing
246322

247-
####Install project dependencies
323+
#### Install project dependencies
248324
```bash
249325
npm install
250326
bower install
251327
```
252328

253-
####Style Guide
329+
#### Style Guide
254330
Please respect the formatting specified in .editorconfig
255331

256-
####Grunt Tasks
332+
#### Grunt Tasks
257333
```grunt default``` Runs jshint & compiles project
258334

259335
```grunt dev``` Opens demo page, starts karma test runner, runs unit tests on src & test folder changes

0 commit comments

Comments
 (0)