@base-framework/base 2.6.1 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/base.js +1 -0
- package/package.json +30 -26
- package/.jshintrc +0 -3
- package/base.js +0 -41
- package/base.min.js +0 -1
- package/core.js +0 -1
- package/data-tracker.js +0 -351
- package/es5/base.js +0 -2968
- package/es5/modules/ajax.js +0 -663
- package/es5/modules/animation.js +0 -188
- package/es5/modules/animations.js +0 -1080
- package/es5/modules/atom.js +0 -65
- package/es5/modules/component.js +0 -1310
- package/es5/modules/data-binder.js +0 -1131
- package/es5/modules/data.js +0 -1808
- package/es5/modules/date.js +0 -525
- package/es5/modules/form-validator.js +0 -324
- package/es5/modules/history.js +0 -126
- package/es5/modules/html-builder.js +0 -461
- package/es5/modules/layout.js +0 -1679
- package/es5/modules/mouse.js +0 -124
- package/es5/modules/nav-link.js +0 -123
- package/es5/modules/olderversions/animations-ease.js +0 -1095
- package/es5/modules/olderversions/animations-update.js +0 -1048
- package/es5/modules/olderversions/base-animations.js +0 -636
- package/es5/modules/olderversions/base-component-class.js +0 -100
- package/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/es5/modules/olderversions/base-mode-1.js +0 -777
- package/es5/modules/olderversions/base-model-class.js +0 -585
- package/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/es5/modules/olderversions/data-tracker.js +0 -187
- package/es5/modules/olderversions/event-update.js +0 -666
- package/es5/modules/olderversions/nav-link.js +0 -119
- package/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/es5/modules/olderversions/router-with-templates.js +0 -701
- package/es5/modules/prototypes/ajax.js +0 -657
- package/es5/modules/prototypes/atom.js +0 -65
- package/es5/modules/prototypes/component.js +0 -972
- package/es5/modules/prototypes/data-binder.js +0 -1089
- package/es5/modules/prototypes/data.js +0 -1290
- package/es5/modules/prototypes/html-builder.js +0 -414
- package/es5/modules/prototypes/layout.js +0 -879
- package/es5/modules/router.js +0 -1680
- package/es5/modules/state.js +0 -274
- package/es6/.jshintrc +0 -3
- package/es6/base.js +0 -41
- package/es6/core.js +0 -1
- package/es6/data-tracker.js +0 -351
- package/es6/events.js +0 -602
- package/es6/legacy/es5/base.js +0 -2968
- package/es6/legacy/es5/modules/ajax.js +0 -663
- package/es6/legacy/es5/modules/animation.js +0 -188
- package/es6/legacy/es5/modules/animations.js +0 -1080
- package/es6/legacy/es5/modules/atom.js +0 -65
- package/es6/legacy/es5/modules/component.js +0 -1310
- package/es6/legacy/es5/modules/data-binder.js +0 -1131
- package/es6/legacy/es5/modules/data.js +0 -1808
- package/es6/legacy/es5/modules/date.js +0 -525
- package/es6/legacy/es5/modules/form-validator.js +0 -324
- package/es6/legacy/es5/modules/history.js +0 -126
- package/es6/legacy/es5/modules/html-builder.js +0 -461
- package/es6/legacy/es5/modules/layout.js +0 -1679
- package/es6/legacy/es5/modules/mouse.js +0 -124
- package/es6/legacy/es5/modules/nav-link.js +0 -123
- package/es6/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
- package/es6/legacy/es5/modules/olderversions/animations-update.js +0 -1048
- package/es6/legacy/es5/modules/olderversions/base-animations.js +0 -636
- package/es6/legacy/es5/modules/olderversions/base-component-class.js +0 -100
- package/es6/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/es6/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/es6/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/es6/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
- package/es6/legacy/es5/modules/olderversions/base-model-class.js +0 -585
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/es6/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/es6/legacy/es5/modules/olderversions/data-tracker.js +0 -187
- package/es6/legacy/es5/modules/olderversions/event-update.js +0 -666
- package/es6/legacy/es5/modules/olderversions/nav-link.js +0 -119
- package/es6/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/es6/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
- package/es6/legacy/es5/modules/prototypes/ajax.js +0 -657
- package/es6/legacy/es5/modules/prototypes/atom.js +0 -65
- package/es6/legacy/es5/modules/prototypes/component.js +0 -972
- package/es6/legacy/es5/modules/prototypes/data-binder.js +0 -1089
- package/es6/legacy/es5/modules/prototypes/data.js +0 -1290
- package/es6/legacy/es5/modules/prototypes/html-builder.js +0 -414
- package/es6/legacy/es5/modules/prototypes/layout.js +0 -879
- package/es6/legacy/es5/modules/router.js +0 -1680
- package/es6/legacy/es5/modules/state.js +0 -274
- package/es6/main.js +0 -1331
- package/es6/modules/ajax/ajax.js +0 -514
- package/es6/modules/animation/animation.js +0 -236
- package/es6/modules/animations/animation-controller.js +0 -231
- package/es6/modules/animations/animation.js +0 -64
- package/es6/modules/animations/attr-movement.js +0 -66
- package/es6/modules/animations/css-movement.js +0 -170
- package/es6/modules/animations/movement.js +0 -131
- package/es6/modules/animations/value.js +0 -187
- package/es6/modules/atom/atom.js +0 -54
- package/es6/modules/component/component.js +0 -230
- package/es6/modules/component/event-helper.js +0 -119
- package/es6/modules/component/jot.js +0 -144
- package/es6/modules/component/state-helper.js +0 -262
- package/es6/modules/component/unit.js +0 -551
- package/es6/modules/data/attrs.js +0 -40
- package/es6/modules/data/basic-data.js +0 -500
- package/es6/modules/data/data-utils.js +0 -29
- package/es6/modules/data/data.js +0 -3
- package/es6/modules/data/deep-data.js +0 -541
- package/es6/modules/data/model-service.js +0 -528
- package/es6/modules/data/model.js +0 -133
- package/es6/modules/data/simple-data.js +0 -33
- package/es6/modules/data-binder/connection-tracker.js +0 -113
- package/es6/modules/data-binder/connection.js +0 -16
- package/es6/modules/data-binder/data-binder.js +0 -352
- package/es6/modules/data-binder/data-pub-sub.js +0 -141
- package/es6/modules/data-binder/data-source.js +0 -56
- package/es6/modules/data-binder/element-source.js +0 -219
- package/es6/modules/data-binder/one-way-connection.js +0 -46
- package/es6/modules/data-binder/one-way-source.js +0 -43
- package/es6/modules/data-binder/source.js +0 -36
- package/es6/modules/data-binder/two-way-connection.js +0 -75
- package/es6/modules/data-binder/two-way-source.js +0 -41
- package/es6/modules/date/date.js +0 -544
- package/es6/modules/history/history.js +0 -89
- package/es6/modules/html-builder/html-builder.js +0 -434
- package/es6/modules/import/import.js +0 -390
- package/es6/modules/layout/layout-builder.js +0 -1269
- package/es6/modules/layout/layout-parser.js +0 -134
- package/es6/modules/layout/watcher-helper.js +0 -282
- package/es6/modules/mouse/mouse.js +0 -114
- package/es6/modules/router/component-helper.js +0 -163
- package/es6/modules/router/history-controller.js +0 -216
- package/es6/modules/router/nav-link.js +0 -124
- package/es6/modules/router/route.js +0 -401
- package/es6/modules/router/router.js +0 -789
- package/es6/modules/router/utils.js +0 -31
- package/es6/modules/state/state-target.js +0 -91
- package/es6/modules/state/state.js +0 -171
- package/es6/package-lock.json +0 -13
- package/es6/package.json +0 -28
- package/es6/shared/objects.js +0 -99
- package/events.js +0 -602
- package/legacy/es5/base.js +0 -2968
- package/legacy/es5/modules/ajax.js +0 -663
- package/legacy/es5/modules/animation.js +0 -188
- package/legacy/es5/modules/animations.js +0 -1080
- package/legacy/es5/modules/atom.js +0 -65
- package/legacy/es5/modules/component.js +0 -1310
- package/legacy/es5/modules/data-binder.js +0 -1131
- package/legacy/es5/modules/data.js +0 -1808
- package/legacy/es5/modules/date.js +0 -525
- package/legacy/es5/modules/form-validator.js +0 -324
- package/legacy/es5/modules/history.js +0 -126
- package/legacy/es5/modules/html-builder.js +0 -461
- package/legacy/es5/modules/layout.js +0 -1679
- package/legacy/es5/modules/mouse.js +0 -124
- package/legacy/es5/modules/nav-link.js +0 -123
- package/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
- package/legacy/es5/modules/olderversions/animations-update.js +0 -1048
- package/legacy/es5/modules/olderversions/base-animations.js +0 -636
- package/legacy/es5/modules/olderversions/base-component-class.js +0 -100
- package/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
- package/legacy/es5/modules/olderversions/base-model-class.js +0 -585
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/legacy/es5/modules/olderversions/data-tracker.js +0 -187
- package/legacy/es5/modules/olderversions/event-update.js +0 -666
- package/legacy/es5/modules/olderversions/nav-link.js +0 -119
- package/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
- package/legacy/es5/modules/prototypes/ajax.js +0 -657
- package/legacy/es5/modules/prototypes/atom.js +0 -65
- package/legacy/es5/modules/prototypes/component.js +0 -972
- package/legacy/es5/modules/prototypes/data-binder.js +0 -1089
- package/legacy/es5/modules/prototypes/data.js +0 -1290
- package/legacy/es5/modules/prototypes/html-builder.js +0 -414
- package/legacy/es5/modules/prototypes/layout.js +0 -879
- package/legacy/es5/modules/router.js +0 -1680
- package/legacy/es5/modules/state.js +0 -274
- package/main.js +0 -1331
- package/modules/ajax/ajax.js +0 -514
- package/modules/animation/animation.js +0 -236
- package/modules/animations/animation-controller.js +0 -231
- package/modules/animations/animation.js +0 -64
- package/modules/animations/attr-movement.js +0 -66
- package/modules/animations/css-movement.js +0 -170
- package/modules/animations/movement.js +0 -131
- package/modules/animations/value.js +0 -187
- package/modules/atom/atom.js +0 -54
- package/modules/component/component.js +0 -230
- package/modules/component/event-helper.js +0 -119
- package/modules/component/jot.js +0 -144
- package/modules/component/state-helper.js +0 -262
- package/modules/component/unit.js +0 -551
- package/modules/data/attrs.js +0 -40
- package/modules/data/basic-data.js +0 -500
- package/modules/data/data-utils.js +0 -29
- package/modules/data/data.js +0 -3
- package/modules/data/deep-data.js +0 -541
- package/modules/data/model-service.js +0 -528
- package/modules/data/model.js +0 -133
- package/modules/data/simple-data.js +0 -33
- package/modules/data-binder/connection-tracker.js +0 -113
- package/modules/data-binder/connection.js +0 -16
- package/modules/data-binder/data-binder.js +0 -352
- package/modules/data-binder/data-pub-sub.js +0 -141
- package/modules/data-binder/data-source.js +0 -56
- package/modules/data-binder/element-source.js +0 -219
- package/modules/data-binder/one-way-connection.js +0 -46
- package/modules/data-binder/one-way-source.js +0 -43
- package/modules/data-binder/source.js +0 -36
- package/modules/data-binder/two-way-connection.js +0 -75
- package/modules/data-binder/two-way-source.js +0 -41
- package/modules/date/date.js +0 -544
- package/modules/history/history.js +0 -89
- package/modules/html-builder/html-builder.js +0 -434
- package/modules/import/import.js +0 -390
- package/modules/layout/layout-builder.js +0 -1269
- package/modules/layout/layout-parser.js +0 -134
- package/modules/layout/watcher-helper.js +0 -282
- package/modules/mouse/mouse.js +0 -114
- package/modules/router/component-helper.js +0 -163
- package/modules/router/history-controller.js +0 -216
- package/modules/router/nav-link.js +0 -124
- package/modules/router/route.js +0 -401
- package/modules/router/router.js +0 -789
- package/modules/router/utils.js +0 -31
- package/modules/state/state-target.js +0 -91
- package/modules/state/state.js +0 -171
- package/shared/objects.js +0 -99
- package/update +0 -16
|
@@ -1,636 +0,0 @@
|
|
|
1
|
-
/* base framework module */
|
|
2
|
-
/*
|
|
3
|
-
javascript animation add and remove with full object
|
|
4
|
-
animation tracking
|
|
5
|
-
*/
|
|
6
|
-
(function()
|
|
7
|
-
{
|
|
8
|
-
"use strict";
|
|
9
|
-
|
|
10
|
-
/* this will add and remove animations */
|
|
11
|
-
base.extend.animations = {
|
|
12
|
-
|
|
13
|
-
/* this class tracks all objects being animated and can
|
|
14
|
-
add and remove them when completed */
|
|
15
|
-
animating:
|
|
16
|
-
{
|
|
17
|
-
objects: [],
|
|
18
|
-
|
|
19
|
-
/* this will create a new animation obj form the params obj
|
|
20
|
-
and add it to the objects array to be tracked.
|
|
21
|
-
@param (object) obj = the animation params
|
|
22
|
-
@return (object) the animation object */
|
|
23
|
-
add: function(obj)
|
|
24
|
-
{
|
|
25
|
-
var animationObj = null,
|
|
26
|
-
self = this;
|
|
27
|
-
|
|
28
|
-
/* we want to setup the animation to remove itself when
|
|
29
|
-
finished */
|
|
30
|
-
var removeAnimation = function(status)
|
|
31
|
-
{
|
|
32
|
-
self.remove(animationObj);
|
|
33
|
-
/* this will check to return the animation call back
|
|
34
|
-
and return the status */
|
|
35
|
-
var callBack = obj.callBack;
|
|
36
|
-
if(typeof callBack === 'function')
|
|
37
|
-
{
|
|
38
|
-
callBack(status);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/* this will create a new animation object and we
|
|
43
|
-
want to add it to the objects array */
|
|
44
|
-
animationObj = new animation(obj, removeAnimation);
|
|
45
|
-
this.objects.push(animationObj);
|
|
46
|
-
return animationObj;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
/* this will stop and remove an animation obj form the
|
|
50
|
-
params obj and remove it from being tracked.
|
|
51
|
-
@param (object) obj = the animation obj
|
|
52
|
-
@return (object) an instance of the animating object */
|
|
53
|
-
remove: function(obj)
|
|
54
|
-
{
|
|
55
|
-
this.stopAnimation(obj);
|
|
56
|
-
|
|
57
|
-
var objects = this.objects;
|
|
58
|
-
var indexNumber = base.inArray(objects, obj);
|
|
59
|
-
if(indexNumber > -1)
|
|
60
|
-
{
|
|
61
|
-
objects.splice(indexNumber, 1);
|
|
62
|
-
}
|
|
63
|
-
return this;
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
/* this will remove and stop any animation still active
|
|
67
|
-
on an element.
|
|
68
|
-
@param (object) element
|
|
69
|
-
@return (object) an instance of the animating object */
|
|
70
|
-
removeByElement: function(element)
|
|
71
|
-
{
|
|
72
|
-
if(element)
|
|
73
|
-
{
|
|
74
|
-
var animating = this.checkAnimating(element);
|
|
75
|
-
if(animating !== false)
|
|
76
|
-
{
|
|
77
|
-
var animations = animating;
|
|
78
|
-
for(var i = 0, maxLength = animations.length; i < maxLength; i++)
|
|
79
|
-
{
|
|
80
|
-
/* we want to remove the animation fron the object array */
|
|
81
|
-
this.remove(animations[i]);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return this;
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
/* this will stop an animation if its still active.
|
|
89
|
-
@param (object) animation = the animation object
|
|
90
|
-
@return (object) an instance of the animating object */
|
|
91
|
-
stopAnimation: function(animation)
|
|
92
|
-
{
|
|
93
|
-
if(animation && typeof animation === 'object')
|
|
94
|
-
{
|
|
95
|
-
if(animation.status !== 'stopped')
|
|
96
|
-
{
|
|
97
|
-
/* we want to stop the animation */
|
|
98
|
-
animation.stop();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return this;
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
/* this will get all active aniamtion objects for an element.
|
|
105
|
-
@param (object) element
|
|
106
|
-
@return (array) an array of animation objects */
|
|
107
|
-
checkAnimating: function(element)
|
|
108
|
-
{
|
|
109
|
-
var animationArray = [];
|
|
110
|
-
|
|
111
|
-
if(element && typeof element === 'object')
|
|
112
|
-
{
|
|
113
|
-
/* we want to get any timers set for our object */
|
|
114
|
-
var objects = this.objects;
|
|
115
|
-
for(var i = 0, maxLength = objects.length; i < maxLength; i++)
|
|
116
|
-
{
|
|
117
|
-
var animation = objects[i];
|
|
118
|
-
if(animation.element === element)
|
|
119
|
-
{
|
|
120
|
-
animationArray.push(animation);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return (animationArray.length >= 1)? animationArray : false;
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
/* this will stop all previous aniamtions on an element.
|
|
128
|
-
@param (object) element = the element
|
|
129
|
-
@return (object) an instance of the animating object */
|
|
130
|
-
stopPreviousAnimations: function(element)
|
|
131
|
-
{
|
|
132
|
-
/* we want to remove the timers and class names
|
|
133
|
-
from the object */
|
|
134
|
-
this.removeByElement(element);
|
|
135
|
-
return this;
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
reset: function()
|
|
139
|
-
{
|
|
140
|
-
this.objects = [];
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
add: function(obj)
|
|
146
|
-
{
|
|
147
|
-
return this.animating.add(obj);
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
remove: function(obj)
|
|
151
|
-
{
|
|
152
|
-
this.animating.remove(obj);
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
/* this will setup the request animation frame to
|
|
156
|
-
allow backwards compat. */
|
|
157
|
-
setupAnimationFrame: function()
|
|
158
|
-
{
|
|
159
|
-
var w = window;
|
|
160
|
-
/* setup request for prefix or setTimeout if
|
|
161
|
-
not supported */
|
|
162
|
-
w.requestAnimationFrame = (
|
|
163
|
-
w.requestAnimationFrame ||
|
|
164
|
-
w.mozRequestAnimationFrame ||
|
|
165
|
-
w.webkitRequestAnimationFrame ||
|
|
166
|
-
w.msRequestAnimationFrame ||
|
|
167
|
-
function(callBack)
|
|
168
|
-
{
|
|
169
|
-
return w.setTimeout(callBack, 1000 / 60);
|
|
170
|
-
}
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
/* setup cancel for prefix or setTimeout if
|
|
174
|
-
not supported */
|
|
175
|
-
w.cancelAnimationFrame = (
|
|
176
|
-
w.cancelAnimationFrame ||
|
|
177
|
-
w.mozCancelAnimationFrame ||
|
|
178
|
-
function(requestID)
|
|
179
|
-
{
|
|
180
|
-
w.clearTimeout(requestID);
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
stop: function(element)
|
|
186
|
-
{
|
|
187
|
-
this.animating.stopPreviousAnimations(element);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/* we want to setup the animation frame to support
|
|
192
|
-
all browsers */
|
|
193
|
-
base.animations.setupAnimationFrame();
|
|
194
|
-
|
|
195
|
-
/*
|
|
196
|
-
animation
|
|
197
|
-
|
|
198
|
-
this will create an animation object that will
|
|
199
|
-
animate a target property on an element over a
|
|
200
|
-
duration.
|
|
201
|
-
|
|
202
|
-
@param (object) paramsObj = the animation params
|
|
203
|
-
@param [(function)] callBack = the function to call back
|
|
204
|
-
when the animation is done
|
|
205
|
-
*/
|
|
206
|
-
var animation = function(paramsObj, callBack)
|
|
207
|
-
{
|
|
208
|
-
/* this is the delay of the animation in milliseconds */
|
|
209
|
-
this.delay = paramsObj.delay || 0;
|
|
210
|
-
this.delayTimer = null;
|
|
211
|
-
|
|
212
|
-
/* this is the animation duration in milliseconds */
|
|
213
|
-
this.duration = paramsObj.duration || 0;
|
|
214
|
-
|
|
215
|
-
/* this will store the element and the element
|
|
216
|
-
property to animate */
|
|
217
|
-
this.element = this.getElement(paramsObj.element);
|
|
218
|
-
this.targetProperty = paramsObj.property;
|
|
219
|
-
this.type = this.getType();
|
|
220
|
-
this.status = 'stopped';
|
|
221
|
-
this.ease = paramsObj.ease || 'linear';
|
|
222
|
-
|
|
223
|
-
this.startTime = null;
|
|
224
|
-
|
|
225
|
-
/* this will be the call back function to return
|
|
226
|
-
when the animation is complete or errors */
|
|
227
|
-
this.callBack = callBack;
|
|
228
|
-
|
|
229
|
-
/* this will setup the fps */
|
|
230
|
-
this.fps = paramsObj.fps || 60;
|
|
231
|
-
|
|
232
|
-
/* this will setup the new animation object and start
|
|
233
|
-
the animation if all is correct or stop and return an
|
|
234
|
-
error */
|
|
235
|
-
this.setup(paramsObj);
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
animation.prototype =
|
|
239
|
-
{
|
|
240
|
-
constructor: animation,
|
|
241
|
-
|
|
242
|
-
/* this will setup the animation to start */
|
|
243
|
-
setup: function(paramsObj)
|
|
244
|
-
{
|
|
245
|
-
if(typeof this.element === 'object' && this.targetProperty)
|
|
246
|
-
{
|
|
247
|
-
if(this.type === 'css')
|
|
248
|
-
{
|
|
249
|
-
this.update = this.updateCss;
|
|
250
|
-
}
|
|
251
|
-
else
|
|
252
|
-
{
|
|
253
|
-
this.update = this.updateAttr;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/* we want to start the animation by the animation
|
|
257
|
-
delay settings */
|
|
258
|
-
var callBack = base.createCallBack(this, this.start, [paramsObj]);
|
|
259
|
-
this.delayTimer = window.setTimeout(callBack, this.delay);
|
|
260
|
-
}
|
|
261
|
-
else
|
|
262
|
-
{
|
|
263
|
-
/* we do not have an element or property to
|
|
264
|
-
animate so we wantto return an error */
|
|
265
|
-
this.updateStatus('error');
|
|
266
|
-
}
|
|
267
|
-
return this;
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
/* this will start the animation by getting the start time
|
|
271
|
-
and starting the animation timer */
|
|
272
|
-
start: function(paramsObj)
|
|
273
|
-
{
|
|
274
|
-
/* we want to setup the start and end values of the
|
|
275
|
-
animation */
|
|
276
|
-
this.combining = false;
|
|
277
|
-
var endValue = paramsObj.endValue;
|
|
278
|
-
this.startValue = this.getStartValue(paramsObj.startValue, endValue);
|
|
279
|
-
|
|
280
|
-
this.value = this.getValue(endValue);
|
|
281
|
-
this.units = this.getUnits(endValue);
|
|
282
|
-
|
|
283
|
-
/* we want to check if we are increasing or
|
|
284
|
-
decreasing the target */
|
|
285
|
-
this.increasing = this.isIncreasing(endValue);
|
|
286
|
-
this.difference = (Math.abs(this.startValue - this.value));
|
|
287
|
-
this.animationCallBack = this.animate.bind(this);
|
|
288
|
-
|
|
289
|
-
/* this will track the time passed and the progress
|
|
290
|
-
of the animation */
|
|
291
|
-
this.startTime = new Date();
|
|
292
|
-
this.timePassed = 0;
|
|
293
|
-
this.progress = 0;
|
|
294
|
-
this.timer = null;
|
|
295
|
-
|
|
296
|
-
this.startTimer();
|
|
297
|
-
return this;
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
stop: function()
|
|
301
|
-
{
|
|
302
|
-
this.stopTimer();
|
|
303
|
-
return this;
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
getType: function()
|
|
307
|
-
{
|
|
308
|
-
var element = this.element;
|
|
309
|
-
return (element.style && this.targetProperty in element.style)? 'css' : 'attr';
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
/* this will get the element that is being used.
|
|
313
|
-
@param (mixed) element = the element selector or object
|
|
314
|
-
@return (object) the element */
|
|
315
|
-
getElement: function(element)
|
|
316
|
-
{
|
|
317
|
-
return (typeof element === 'string')? document.querySelector(element) : element;
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
/* this will get the units of the property being animated.
|
|
321
|
-
@param (string) text = the value being modified
|
|
322
|
-
@return (string) the type of units */
|
|
323
|
-
getUnits: function(text)
|
|
324
|
-
{
|
|
325
|
-
if(typeof text !== 'undefined')
|
|
326
|
-
{
|
|
327
|
-
text = this.getString(text);
|
|
328
|
-
|
|
329
|
-
/* we need to remove the numbers or plus or minus equals
|
|
330
|
-
to get the units */
|
|
331
|
-
var pattern = /([0-9.\-\+=])/g;
|
|
332
|
-
return text.replace(pattern, '');
|
|
333
|
-
}
|
|
334
|
-
return '';
|
|
335
|
-
},
|
|
336
|
-
|
|
337
|
-
/* this will get start value of the property being animated.
|
|
338
|
-
@param (string) value = the value being modified
|
|
339
|
-
@return (string) the type of units */
|
|
340
|
-
getStartValue: function(value, end)
|
|
341
|
-
{
|
|
342
|
-
var start = 0;
|
|
343
|
-
if(typeof end !== 'undefined')
|
|
344
|
-
{
|
|
345
|
-
end = this.getString(end);
|
|
346
|
-
/* we want to check if we have a plus or minus equals to
|
|
347
|
-
show that we are using the current position as the start */
|
|
348
|
-
var pattern = /(\+=|-=)/g,
|
|
349
|
-
matches = end.match(pattern);
|
|
350
|
-
if(matches)
|
|
351
|
-
{
|
|
352
|
-
this.combining = true;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if(typeof value === 'undefined')
|
|
357
|
-
{
|
|
358
|
-
/* we want to get the elements current target value
|
|
359
|
-
as the starting value but we need to get it by the
|
|
360
|
-
property type */
|
|
361
|
-
if(this.type === 'css')
|
|
362
|
-
{
|
|
363
|
-
start = this.getValue(base.css(this.element, this.targetProperty));
|
|
364
|
-
}
|
|
365
|
-
else
|
|
366
|
-
{
|
|
367
|
-
start = this.element[this.targetProperty];
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
else
|
|
371
|
-
{
|
|
372
|
-
start = this.getValue(value);
|
|
373
|
-
}
|
|
374
|
-
return start;
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
/* this will convert any type to a string
|
|
378
|
-
@param (mixed) value = the value to convert
|
|
379
|
-
@return (string) the value string */
|
|
380
|
-
getString: function(value)
|
|
381
|
-
{
|
|
382
|
-
return (typeof value !== 'string')? value.toString() : value;
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
/* this will get the number from an value and remove
|
|
386
|
-
any other marks including chars.
|
|
387
|
-
@param (mixed) text = the text to get the value from
|
|
388
|
-
@return (number) the number value */
|
|
389
|
-
getValue: function(text)
|
|
390
|
-
{
|
|
391
|
-
if(typeof text !== 'undefined')
|
|
392
|
-
{
|
|
393
|
-
var cssPattern = /(?:(\w+\s*)\(.+\))/g;
|
|
394
|
-
|
|
395
|
-
text.replace(cssPattern, function(a, b, c, d)
|
|
396
|
-
{
|
|
397
|
-
console.log(arguments)
|
|
398
|
-
});
|
|
399
|
-
var matches = text.match(cssPattern);
|
|
400
|
-
if(matches)
|
|
401
|
-
{
|
|
402
|
-
console.log(matches)
|
|
403
|
-
var cssValue =
|
|
404
|
-
{
|
|
405
|
-
method: matches[1],
|
|
406
|
-
params: []
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
/* we need to remove any non numeric data from the value
|
|
410
|
-
and convert to number after */
|
|
411
|
-
var pattern = /(\+=|-=|[^0-9.-])/g;
|
|
412
|
-
text = this.getString(text);
|
|
413
|
-
return (text.replace(pattern, '') * 1);
|
|
414
|
-
}
|
|
415
|
-
return 0;
|
|
416
|
-
},
|
|
417
|
-
|
|
418
|
-
/* this will check if the element is increasing or decreasing the
|
|
419
|
-
target.
|
|
420
|
-
@return (bool) true or false */
|
|
421
|
-
isIncreasing: function(endValue)
|
|
422
|
-
{
|
|
423
|
-
/* we want to check if we are adding to the start or
|
|
424
|
-
just modifying the value */
|
|
425
|
-
var endTotal = this.value;
|
|
426
|
-
var startValue = this.startValue;
|
|
427
|
-
if(this.combining === true)
|
|
428
|
-
{
|
|
429
|
-
endTotal = (this.getString(endValue).indexOf("-") === -1)? (startValue + this.value) : startValue - this.value;
|
|
430
|
-
}
|
|
431
|
-
return (endTotal >= startValue)? true : false;
|
|
432
|
-
},
|
|
433
|
-
|
|
434
|
-
/* this will get the delta to be used with the animation.
|
|
435
|
-
@return (number) the current delta */
|
|
436
|
-
delta: function()
|
|
437
|
-
{
|
|
438
|
-
var delta = 0,
|
|
439
|
-
t = this.progress;
|
|
440
|
-
|
|
441
|
-
switch(this.ease)
|
|
442
|
-
{
|
|
443
|
-
case 'easeInOut':
|
|
444
|
-
case 'easeInOutQuad':
|
|
445
|
-
delta = t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
446
|
-
break;
|
|
447
|
-
case 'easeIn':
|
|
448
|
-
case 'easeInQuad':
|
|
449
|
-
delta = (t * t);
|
|
450
|
-
break;
|
|
451
|
-
case 'easeInCubic':
|
|
452
|
-
delta = (t * t * t);
|
|
453
|
-
break;
|
|
454
|
-
case 'easeInQuart':
|
|
455
|
-
delta = (t * t * t * t);
|
|
456
|
-
break;
|
|
457
|
-
case 'easeInCirc':
|
|
458
|
-
delta = (1 - Math.sin(Math.acos(t)));
|
|
459
|
-
break;
|
|
460
|
-
case 'easeOut':
|
|
461
|
-
case 'easeOutQuad':
|
|
462
|
-
delta = (t * (2 - t));
|
|
463
|
-
break;
|
|
464
|
-
case 'easeOutCubic':
|
|
465
|
-
delta = ((--t) * t * t + 1);
|
|
466
|
-
break;
|
|
467
|
-
case 'easeOutQuart':
|
|
468
|
-
delta = (1 - (--t) * t * t * t);
|
|
469
|
-
break;
|
|
470
|
-
case 'linear':
|
|
471
|
-
delta = t;
|
|
472
|
-
break;
|
|
473
|
-
default:
|
|
474
|
-
delta = t;
|
|
475
|
-
}
|
|
476
|
-
return delta;
|
|
477
|
-
},
|
|
478
|
-
|
|
479
|
-
/* this will perform the animation on the element by
|
|
480
|
-
incrementally updating the element object property
|
|
481
|
-
by the timed progress. */
|
|
482
|
-
animate: function()
|
|
483
|
-
{
|
|
484
|
-
this.timePassed = new Date() - this.startTime;
|
|
485
|
-
var progress = this.timePassed / this.duration;
|
|
486
|
-
progress = this.progress = (progress > 1)? 1 : progress;
|
|
487
|
-
|
|
488
|
-
var delta = this.delta();
|
|
489
|
-
|
|
490
|
-
/* this will get the next stop in our animation
|
|
491
|
-
that should be added to the target prop */
|
|
492
|
-
var step = this.step(delta);
|
|
493
|
-
|
|
494
|
-
/* we want to check to add or subtract the step
|
|
495
|
-
by the increase prop */
|
|
496
|
-
var start = this.startValue;
|
|
497
|
-
var totalValue = (this.increasing)? (start + step) : (start - step),
|
|
498
|
-
propValue = (totalValue) + this.units;
|
|
499
|
-
|
|
500
|
-
/* we want to check if we are animating a css prop or
|
|
501
|
-
a other property */
|
|
502
|
-
this.update(propValue);
|
|
503
|
-
|
|
504
|
-
/* if the progress is 1 the animation is complete */
|
|
505
|
-
if(progress >= 1)
|
|
506
|
-
{
|
|
507
|
-
this.stopTimer();
|
|
508
|
-
this.updateStatus('completed');
|
|
509
|
-
}
|
|
510
|
-
else
|
|
511
|
-
{
|
|
512
|
-
this.timer = window.requestAnimationFrame(this.animationCallBack);
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
|
|
516
|
-
step: function(delta)
|
|
517
|
-
{
|
|
518
|
-
var step;
|
|
519
|
-
|
|
520
|
-
var self = this;
|
|
521
|
-
if(this.combining === true)
|
|
522
|
-
{
|
|
523
|
-
step = function(delta)
|
|
524
|
-
{
|
|
525
|
-
return (self.value * delta);
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
else
|
|
529
|
-
{
|
|
530
|
-
step = function(delta)
|
|
531
|
-
{
|
|
532
|
-
return (self.difference * delta);
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
return (this.step = step).apply(this, base.listToArray(arguments));
|
|
536
|
-
},
|
|
537
|
-
|
|
538
|
-
/* this should be overridden by the update
|
|
539
|
-
property type being animated.
|
|
540
|
-
@param (mixed) value */
|
|
541
|
-
update: function(value)
|
|
542
|
-
{
|
|
543
|
-
|
|
544
|
-
},
|
|
545
|
-
|
|
546
|
-
updateCss: function(value)
|
|
547
|
-
{
|
|
548
|
-
this.element.style[this.targetProperty] = value;
|
|
549
|
-
},
|
|
550
|
-
|
|
551
|
-
updateAttr: function(value)
|
|
552
|
-
{
|
|
553
|
-
this.element[this.targetProperty] = value;
|
|
554
|
-
},
|
|
555
|
-
|
|
556
|
-
updateStatus: function(status)
|
|
557
|
-
{
|
|
558
|
-
var self = this;
|
|
559
|
-
var action = function()
|
|
560
|
-
{
|
|
561
|
-
switch(status)
|
|
562
|
-
{
|
|
563
|
-
case 'started':
|
|
564
|
-
break;
|
|
565
|
-
case 'stopped':
|
|
566
|
-
break;
|
|
567
|
-
case 'completed':
|
|
568
|
-
case 'error':
|
|
569
|
-
self.checkCallBack();
|
|
570
|
-
break;
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
/* we want to save the status and call the
|
|
575
|
-
action function */
|
|
576
|
-
this.status = status;
|
|
577
|
-
action();
|
|
578
|
-
},
|
|
579
|
-
|
|
580
|
-
checkCallBack: function()
|
|
581
|
-
{
|
|
582
|
-
var callBack = this.callBack;
|
|
583
|
-
if(typeof callBack === 'function')
|
|
584
|
-
{
|
|
585
|
-
callBack.call(null, this.status);
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
|
|
589
|
-
/* this will start the animation by setting up the
|
|
590
|
-
animation timer. */
|
|
591
|
-
startTimer: function()
|
|
592
|
-
{
|
|
593
|
-
/* this will check to stop any previous timer before
|
|
594
|
-
creating a new timer */
|
|
595
|
-
this.stopTimer();
|
|
596
|
-
|
|
597
|
-
/* we want to call the animation first to not show a
|
|
598
|
-
delay in the animation before the callback is called */
|
|
599
|
-
this.updateStatus('started');
|
|
600
|
-
this.animate();
|
|
601
|
-
return this;
|
|
602
|
-
},
|
|
603
|
-
|
|
604
|
-
/* this will stop the animation timer if still setup */
|
|
605
|
-
stopTimer: function()
|
|
606
|
-
{
|
|
607
|
-
var w = window;
|
|
608
|
-
if(this.timer)
|
|
609
|
-
{
|
|
610
|
-
w.cancelAnimationFrame(this.timer);
|
|
611
|
-
this.updateStatus('stopped');
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
if(this.delayTimer)
|
|
615
|
-
{
|
|
616
|
-
w.clearTimeout(this.delayTimer);
|
|
617
|
-
}
|
|
618
|
-
return this;
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
/* this will add an animation to an element.
|
|
623
|
-
@param (object) paramsObj = the animation params
|
|
624
|
-
@return (object) the animation object */
|
|
625
|
-
base.extend.addAnimation = function(paramsObj)
|
|
626
|
-
{
|
|
627
|
-
return base.animations.add(paramsObj);
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
/* this will stop all animations on an element.
|
|
631
|
-
@param (object) element = the element */
|
|
632
|
-
base.extend.stopAnimations = function(element)
|
|
633
|
-
{
|
|
634
|
-
base.animations.stop(element);
|
|
635
|
-
};
|
|
636
|
-
})();
|