Skip to content

Commit

Permalink
Merge pull request #358 from radiolips/demo/anijs
Browse files Browse the repository at this point in the history
Demo/anijs
  • Loading branch information
radiolips committed Feb 24, 2016
2 parents cac983e + 5a427dd commit a51a802
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions demo/anijs.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h1>AniJS demo</h1>
</div>

<div>
<h4 data-anijs="if: added, do: swing animated, on: $gridstack">Widget added</h4>
<h4>Widget added</h4>
</div>

<br/>
Expand All @@ -57,9 +57,14 @@ <h4 data-anijs="if: added, do: swing animated, on: $gridstack">Widget added</h4>
$('.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() {
Expand All @@ -68,8 +73,15 @@ <h4 data-anijs="if: added, do: swing animated, on: $gridstack">Widget added</h4>

function addNewWidget() {
var grid = $('.grid-stack').data('gridstack');
grid.addWidget($('<div class="grid-stack-item-content"></div>'), 0, 0, Math.floor(1 + 3 * Math.random()), Math.floor(1 + 3 * Math.random()), true);
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){
$('.grid-stack-item').attr('data-anijs', '');
};
});
</script>
</body>
Expand Down

0 comments on commit a51a802

Please sign in to comment.