Skip to content

Commit

Permalink
fix(scrollView): stop polluting global.core
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Apr 30, 2014
1 parent d8d9362 commit 8992e7c
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.
Expand Down Expand Up @@ -221,15 +214,15 @@
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);
}
};

// Mark as running
running[id] = true;

// Init first step
core.effect.Animate.requestAnimationFrame(step, root);
zyngaCore.effect.Animate.requestAnimationFrame(step, root);

// Return unique animation ID
return id;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -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);

},

Expand Down

0 comments on commit 8992e7c

Please sign in to comment.