From fe63aa08f9e2ca710ba8577b27e87d1d7163274b Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Wed, 7 Aug 2013 16:40:31 -0700 Subject: [PATCH] AnimatedEach: configure which events to animate --- packages/animation/animated_each.js | 30 ++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/animation/animated_each.js b/packages/animation/animated_each.js index 32064d9697..5cc88a4d1f 100644 --- a/packages/animation/animated_each.js +++ b/packages/animation/animated_each.js @@ -1,6 +1,8 @@ // XXX another full pass on this all. AnimatedEach = { - apply: function (el) { + apply: function (el, events) { + events = events || ['insert', 'remove', 'move']; + var animateIn = function (n, parent, next, onComplete) { parent.insertBefore(n, next); var $n = $(n); @@ -87,22 +89,32 @@ AnimatedEach = { } }; - $(el)[0].$uihooks = { - insertElement: function (n, parent, next) { + // xcxc chained hooks? + $(el)[0].$uihooks = {}; + + if (_.contains(events, 'insert')) { + $(el)[0].$uihooks.insertElement = function (n, parent, next) { runOrQueueIfMoving(function () { var onComplete = dequeuePlanned ? null : dequeue; dequeuePlanned = true; animateIn(n, parent, next, onComplete); }); - }, - removeElement: function (n) { + }; + } + + if (_.contains(events, 'remove')) { + $(el)[0].$uihooks.removeElement = function (n) { runOrQueueIfMoving(function () { var onComplete = dequeuePlanned ? null : dequeue; dequeuePlanned = true; animateOut(n, onComplete); }); - }, - moveElement: function (n, parent, next) { + }; + } + + + if (_.contains(events, 'move')) { + $(el)[0].$uihooks.moveElement = function (n, parent, next) { runOrQueue(function () { moveActive = true; @@ -143,7 +155,7 @@ AnimatedEach = { dequeue(); }); }); - } - }; + }; + } } }; \ No newline at end of file