forked from gridstack/gridstack.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
anijs.html
59 lines (52 loc) · 1.92 KB
/
anijs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>AniJS demo</title>
<link rel="stylesheet" href="https://anijs.github.io/lib/anicollection/anicollection.css" />
<link rel="stylesheet" href="demo.css"/>
<script src="../src/jquery.js"></script>
<script src="../src/gridstack.js"></script>
<script src="../src/jquery-ui.js"></script>
<script src="../src/gridstack.jQueryUI.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/AniJS/0.9.3/anijs.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>AniJS demo</h1>
<div>
<a onClick="addWidget()" class="btn btn-primary" href="#">Add Widget</a>
</div>
<h4>Widget added</h4>
<br>
<div class="grid-stack"></div>
</div>
<script type="text/javascript">
var grid = GridStack.init();
var self = this;
grid.on('added', function(e, items) {
// add anijs data to gridstack item
for (var i = 0; i < items.length; i++) {
items[i].el.setAttribute('data-anijs', 'if: added, do: swing animated, after: $removeAnimations, on: $gridstack');
}
AniJS.run();
self.gridstackNotifier = AniJS.getNotifier('gridstack');
// fire added event!
self.gridstackNotifier.dispatchEvent('added');
});
function addWidget() {
grid.addWidget('<div><div class="grid-stack-item-content"></div></div>', 0, 0, Math.floor(1 + 3 * Math.random()), Math.floor(1 + 3 * Math.random()), true);
};
var animationHelper = AniJS.getHelper();
//Defining removeAnimations to remove existing animations
animationHelper.removeAnimations = function(e, animationContext) {
document.querySelectorAll('.grid-stack-item').forEach( function(el) {
el.removeAttribute('data-anijs');
});
}
addWidget();
</script>
</body>
</html>