From b44308b4ed13c575a6ee301588f8dadd3e7d38ec Mon Sep 17 00:00:00 2001 From: Dylan Weiss Date: Tue, 23 Feb 2016 21:16:12 -0500 Subject: [PATCH] Animate widgets. Just for troolee. --- demo/anijs.html | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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', ''); + }; });