diff --git a/demo/anijs.html b/demo/anijs.html
index bd95284..dc6f933 100644
--- a/demo/anijs.html
+++ b/demo/anijs.html
@@ -42,7 +42,7 @@
-
Widget added
+ Widget added
@@ -57,9 +57,14 @@
$('.grid-stack').gridstack();
var self = this;
this.grid = $('.grid-stack').data('gridstack');
- AniJS.run();
- self.gridstackNotifier = AniJS.getNotifier('gridstack');
$('.grid-stack').on('added', function(event, items) {
+ // add anijs data to gridstack item
+ for (var i = 0; i < items.length; i++) {
+ $(items[i].el[0]).attr('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');
});
$('#add-widget').click(function() {
@@ -68,8 +73,15 @@
function addNewWidget() {
var grid = $('.grid-stack').data('gridstack');
- grid.addWidget($(''), 0, 0, Math.floor(1 + 3 * Math.random()), Math.floor(1 + 3 * Math.random()), true);
+ grid.addWidget($(''), 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){
+ $('.grid-stack-item').attr('data-anijs', '');
+ };
});