Skip to content

Commit 8992e7c

Browse files
committed
fix(scrollView): stop polluting global.core
1 parent d8d9362 commit 8992e7c

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

Diff for: js/views/scrollView.js

+11-18
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* rendering. This eases a lot of cases where it might be pretty complex to break down a state
2323
* based on the pure time difference.
2424
*/
25+
var zyngaCore = { effect: {} };
2526
(function(global) {
2627
var time = Date.now || function() {
2728
return +new Date();
@@ -31,15 +32,7 @@
3132
var running = {};
3233
var counter = 1;
3334

34-
// Create namespaces
35-
if (!global.core) {
36-
var core = global.core = { effect : {} };
37-
38-
} else if (!core.effect) {
39-
core.effect = {};
40-
}
41-
42-
core.effect.Animate = {
35+
zyngaCore.effect.Animate = {
4336

4437
/**
4538
* A requestAnimationFrame wrapper / polyfill.
@@ -221,15 +214,15 @@
221214
completedCallback && completedCallback(desiredFrames - (dropCounter / ((now - start) / millisecondsPerSecond)), id, percent === 1 || duration == null);
222215
} else if (render) {
223216
lastFrame = now;
224-
core.effect.Animate.requestAnimationFrame(step, root);
217+
zyngaCore.effect.Animate.requestAnimationFrame(step, root);
225218
}
226219
};
227220

228221
// Mark as running
229222
running[id] = true;
230223

231224
// Init first step
232-
core.effect.Animate.requestAnimationFrame(step, root);
225+
zyngaCore.effect.Animate.requestAnimationFrame(step, root);
233226

234227
// Return unique animation ID
235228
return id;
@@ -1274,7 +1267,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
12741267

12751268
// Stop deceleration
12761269
if (self.__isDecelerating) {
1277-
core.effect.Animate.stop(self.__isDecelerating);
1270+
zyngaCore.effect.Animate.stop(self.__isDecelerating);
12781271
self.__isDecelerating = false;
12791272
}
12801273

@@ -1349,7 +1342,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
13491342

13501343
// Stop deceleration
13511344
if (self.__isDecelerating) {
1352-
core.effect.Animate.stop(self.__isDecelerating);
1345+
zyngaCore.effect.Animate.stop(self.__isDecelerating);
13531346
self.__isDecelerating = false;
13541347
}
13551348

@@ -1481,14 +1474,14 @@ ionic.views.Scroll = ionic.views.View.inherit({
14811474

14821475
// Stop deceleration
14831476
if (self.__isDecelerating) {
1484-
core.effect.Animate.stop(self.__isDecelerating);
1477+
zyngaCore.effect.Animate.stop(self.__isDecelerating);
14851478
self.__isDecelerating = false;
14861479
self.__interruptedAnimation = true;
14871480
}
14881481

14891482
// Stop animation
14901483
if (self.__isAnimating) {
1491-
core.effect.Animate.stop(self.__isAnimating);
1484+
zyngaCore.effect.Animate.stop(self.__isAnimating);
14921485
self.__isAnimating = false;
14931486
self.__interruptedAnimation = true;
14941487
}
@@ -1871,7 +1864,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
18711864
// Remember whether we had an animation, then we try to continue based on the current "drive" of the animation
18721865
var wasAnimating = self.__isAnimating;
18731866
if (wasAnimating) {
1874-
core.effect.Animate.stop(wasAnimating);
1867+
zyngaCore.effect.Animate.stop(wasAnimating);
18751868
self.__isAnimating = false;
18761869
}
18771870

@@ -1924,7 +1917,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
19241917
};
19251918

19261919
// When continuing based on previous animation we choose an ease-out animation instead of ease-in-out
1927-
self.__isAnimating = core.effect.Animate.start(step, verify, completed, self.options.animationDuration, wasAnimating ? easeOutCubic : easeInOutCubic);
1920+
self.__isAnimating = zyngaCore.effect.Animate.start(step, verify, completed, self.options.animationDuration, wasAnimating ? easeOutCubic : easeInOutCubic);
19281921

19291922
} else {
19301923

@@ -2056,7 +2049,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
20562049
};
20572050

20582051
// Start animation and switch on flag
2059-
self.__isDecelerating = core.effect.Animate.start(step, verify, completed);
2052+
self.__isDecelerating = zyngaCore.effect.Animate.start(step, verify, completed);
20602053

20612054
},
20622055

0 commit comments

Comments
 (0)