Skip to content

Commit 9175791

Browse files
committed
Merge pull request #357 from radiolips/demo/anijs
Demo/anijs
2 parents e34407d + ab6df29 commit 9175791

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com
3939
- [IE8 support](#ie8-support)
4040
- [Nested grids](#nested-grids)
4141
- [Resizing active grid](#resizing-active-grid)
42+
- [Using AniJS](#using-anijs)
4243
- [The Team](#the-team)
4344
- [Changes](#changes)
4445
- [v0.2.5-dev (Development version)](#v025-dev-development-version)
@@ -440,6 +441,10 @@ See example: [Nested grid demo](http://troolee.github.io/gridstack.js/demo/neste
440441
Resizing on-the-fly is possible, though experimental. This may be used to make gridstack responsive. gridstack will change the total number of columns and will attempt to update the width and x values of each widget to be more logical.
441442
See example: [Responsive grid demo](http://troolee.github.io/gridstack.js/demo/responsive.html)
442443

444+
## Using AniJS
445+
446+
Using AniJS with gridstack is a breeze. In the following example, a listener is added that gets triggered by a widget being added.
447+
See example: [AniJS demo](http://troolee.github.io/gridstack.js/demo/anijs.html)
443448

444449
The Team
445450
========

demo/anijs.html

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<!--[if lt IE 9]>
5+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
6+
<![endif]-->
7+
8+
<meta charset="utf-8" />
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
10+
<meta name="viewport" content="width=device-width, initial-scale=1" />
11+
<title>AniJS demo</title>
12+
13+
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
14+
<link rel="stylesheet" href="../dist/gridstack.css"/>
15+
<link rel="stylesheet" href="//anijs.github.io/lib/anicollection/anicollection.css" />
16+
17+
18+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
19+
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
20+
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
21+
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
22+
<script src="../dist/gridstack.js"></script>
23+
24+
<style type="text/css">
25+
.grid-stack {
26+
background: lightgoldenrodyellow;
27+
}
28+
29+
.grid-stack-item-content {
30+
color: #2c3e50;
31+
text-align: center;
32+
background-color: #18bc9c;
33+
}
34+
</style>
35+
</head>
36+
<body>
37+
<div class="container-fluid">
38+
<h1>AniJS demo</h1>
39+
40+
<div>
41+
<a class="btn btn-default" id="add-widget" href="#">Add Widget</a>
42+
</div>
43+
44+
<div>
45+
<h4 data-anijs="if: added, do: swing animated, on: $gridstack">Widget added</h4>
46+
</div>
47+
48+
<br/>
49+
50+
<div class="grid-stack">
51+
</div>
52+
</div>
53+
54+
<script src="//cdnjs.cloudflare.com/ajax/libs/AniJS/0.9.3/anijs.js"></script>
55+
<script type="text/javascript">
56+
$(function () {
57+
$('.grid-stack').gridstack();
58+
var self = this;
59+
this.grid = $('.grid-stack').data('gridstack');
60+
AniJS.run();
61+
self.gridstackNotifier = AniJS.getNotifier('gridstack');
62+
$('.grid-stack').on('added', function(event, items) {
63+
self.gridstackNotifier.dispatchEvent('added');
64+
});
65+
$('#add-widget').click(function() {
66+
addNewWidget();
67+
});
68+
69+
function addNewWidget() {
70+
var grid = $('.grid-stack').data('gridstack');
71+
grid.addWidget($('<div class="grid-stack-item-content"></div>'), 0, 0, Math.floor(1 + 3 * Math.random()), Math.floor(1 + 3 * Math.random()), true);
72+
}
73+
});
74+
</script>
75+
</body>
76+
</html>

demo/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<li><a href="rtl.html">RTL demo</a></li>
1414
<li><a href="serialization.html">Serialization demo</a></li>
1515
<li><a href="two.html">Two grids demo</a></li>
16+
<li><a href="responsive.html">Resize grid (responsive) demo</a></li>
17+
<li><a href="anijs.html">AniJS demo</a></li>
1618
</ul>
1719
</body>
1820
</html>

0 commit comments

Comments
 (0)