From 8992e7c903543340b50f3074a43eff3e1b884b45 Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Wed, 30 Apr 2014 09:16:23 -0600 Subject: [PATCH] fix(scrollView): stop polluting global.core --- js/views/scrollView.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/js/views/scrollView.js b/js/views/scrollView.js index 3abf07211b4..26c3f32255b 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -22,6 +22,7 @@ * rendering. This eases a lot of cases where it might be pretty complex to break down a state * based on the pure time difference. */ +var zyngaCore = { effect: {} }; (function(global) { var time = Date.now || function() { return +new Date(); @@ -31,15 +32,7 @@ var running = {}; var counter = 1; - // Create namespaces - if (!global.core) { - var core = global.core = { effect : {} }; - - } else if (!core.effect) { - core.effect = {}; - } - - core.effect.Animate = { + zyngaCore.effect.Animate = { /** * A requestAnimationFrame wrapper / polyfill. @@ -221,7 +214,7 @@ completedCallback && completedCallback(desiredFrames - (dropCounter / ((now - start) / millisecondsPerSecond)), id, percent === 1 || duration == null); } else if (render) { lastFrame = now; - core.effect.Animate.requestAnimationFrame(step, root); + zyngaCore.effect.Animate.requestAnimationFrame(step, root); } }; @@ -229,7 +222,7 @@ running[id] = true; // Init first step - core.effect.Animate.requestAnimationFrame(step, root); + zyngaCore.effect.Animate.requestAnimationFrame(step, root); // Return unique animation ID return id; @@ -1274,7 +1267,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ // Stop deceleration if (self.__isDecelerating) { - core.effect.Animate.stop(self.__isDecelerating); + zyngaCore.effect.Animate.stop(self.__isDecelerating); self.__isDecelerating = false; } @@ -1349,7 +1342,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ // Stop deceleration if (self.__isDecelerating) { - core.effect.Animate.stop(self.__isDecelerating); + zyngaCore.effect.Animate.stop(self.__isDecelerating); self.__isDecelerating = false; } @@ -1481,14 +1474,14 @@ ionic.views.Scroll = ionic.views.View.inherit({ // Stop deceleration if (self.__isDecelerating) { - core.effect.Animate.stop(self.__isDecelerating); + zyngaCore.effect.Animate.stop(self.__isDecelerating); self.__isDecelerating = false; self.__interruptedAnimation = true; } // Stop animation if (self.__isAnimating) { - core.effect.Animate.stop(self.__isAnimating); + zyngaCore.effect.Animate.stop(self.__isAnimating); self.__isAnimating = false; self.__interruptedAnimation = true; } @@ -1871,7 +1864,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ // Remember whether we had an animation, then we try to continue based on the current "drive" of the animation var wasAnimating = self.__isAnimating; if (wasAnimating) { - core.effect.Animate.stop(wasAnimating); + zyngaCore.effect.Animate.stop(wasAnimating); self.__isAnimating = false; } @@ -1924,7 +1917,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ }; // When continuing based on previous animation we choose an ease-out animation instead of ease-in-out - self.__isAnimating = core.effect.Animate.start(step, verify, completed, self.options.animationDuration, wasAnimating ? easeOutCubic : easeInOutCubic); + self.__isAnimating = zyngaCore.effect.Animate.start(step, verify, completed, self.options.animationDuration, wasAnimating ? easeOutCubic : easeInOutCubic); } else { @@ -2056,7 +2049,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ }; // Start animation and switch on flag - self.__isDecelerating = core.effect.Animate.start(step, verify, completed); + self.__isDecelerating = zyngaCore.effect.Animate.start(step, verify, completed); },