@angular-wave/angular.ts 0.0.1 → 0.0.2
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/Makefile +1 -1
- package/dist/angular-ts.cjs.js +503 -1686
- package/dist/angular-ts.esm.js +503 -1686
- package/dist/angular-ts.umd.js +503 -1686
- package/package.json +1 -1
- package/src/animations/{animateCss.js → animate-css.js} +0 -1
- package/src/animations/animation.js +428 -431
- package/src/animations/module.js +9 -9
- package/src/core/compile.js +4 -1101
- package/src/core/compile.md +1192 -0
- package/src/core/location.js +1 -1
- package/src/core/utils.js +1 -1
- package/src/directive/a.js +1 -1
- package/src/directive/attrs.js +1 -1
- package/src/directive/csp.md +87 -0
- package/src/directive/input.js +3 -3
- package/src/directive/{ngModel.js → model.js} +1 -1
- package/src/directive/select.js +5 -5
- package/src/jqLite.js +0 -12
- package/src/public.js +24 -24
- package/src/services/log.js +66 -116
- package/src/services/log.md +39 -0
- package/test/jqlite.spec.js +0 -31
- package/test/messages/messages.spec.js +1 -1
- package/test/ng/compile.spec.js +13 -13
- package/test/ng/directive/model-options.spec.js +1 -1
- package/test/ng/directive/model.spec.js +1 -1
- package/test/ng/directive/options.spec.js +61 -61
- package/test/ng/directive/select.spec.js +22 -22
- package/test/ng/http-backend.spec.js +1 -1
- package/test/ng/on.spec.js +1 -1
- package/test/ng/prop.spec.js +54 -62
- package/test/ng/sanitize-uri.spec.js +1 -1
- package/test/ng/scope.spec.js +1 -1
- package/types/jqlite.d.ts +1 -32
- package/src/core/attributes.js +0 -199
- package/src/directive/ngCsp.js +0 -82
- /package/src/animations/{animateCache.js → animate-cache.js} +0 -0
- /package/src/animations/{animateChildrenDirective.js → animate-children-directive.js} +0 -0
- /package/src/animations/{animateCssDriver.js → animate-css-driver.js} +0 -0
- /package/src/animations/{animateJsDriver.js → animate-js-driver.js} +0 -0
- /package/src/animations/{animateJs.js → animate-js.js} +0 -0
- /package/src/animations/{animateQueue.js → animate-queue.js} +0 -0
- /package/src/animations/{ngAnimateSwap.js → animate-swap.js} +0 -0
- /package/src/animations/{rafScheduler.js → raf-scheduler.js} +0 -0
- /package/src/core/{animateCss.js → animate-css.js} +0 -0
- /package/src/core/{animateRunner.js → animate-runner.js} +0 -0
- /package/src/core/{exceptionHandler.js → exception-handler.js} +0 -0
- /package/src/core/{intervalFactory.js → interval-factory.js} +0 -0
- /package/src/core/{rootScope.js → root-scope.js} +0 -0
- /package/src/core/{sanitizeUri.js → sanitize-uri.js} +0 -0
- /package/src/core/{taskTrackerFactory.js → task-tracker-factory.js} +0 -0
- /package/src/directive/{ngClass.js → class.js} +0 -0
- /package/src/directive/{ngController.js → controller.js} +0 -0
- /package/src/directive/{ngIf.js → if.js} +0 -0
- /package/src/directive/{ngInclude.js → include.js} +0 -0
- /package/src/directive/{ngModelOptions.js → model-options.js} +0 -0
- /package/src/directive/{ngOptions.js → options.js} +0 -0
- /package/src/directive/{ngRef.js → ref.js} +0 -0
- /package/src/directive/{ngRepeat.js → repeat.js} +0 -0
- /package/src/directive/{ngShowHide.js → show-hide.js} +0 -0
- /package/src/directive/{ngSwitch.js → switch.js} +0 -0
- /package/src/directive/{ngTransclude.js → transclude.js} +0 -0
- /package/src/{routeToRegExp.js → route-to-reg-exp.js} +0 -0
- /package/src/services/{anchorScroll.js → anchor-scroll.js} +0 -0
- /package/src/services/{cacheFactory.js → cache-factory.js} +0 -0
- /package/src/services/{cookieReader.js → cookie-reader.js} +0 -0
- /package/src/services/{httpBackend.js → http-backend.js} +0 -0
- /package/src/services/{templateRequest.js → template-request.js} +0 -0
- /package/test/ng/{anomate.spec.js → animate.spec.js} +0 -0
|
@@ -9,498 +9,495 @@ import {
|
|
|
9
9
|
prepareAnimationOptions,
|
|
10
10
|
} from "./shared";
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
animation.domNode,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
69
|
-
}
|
|
12
|
+
export function $$AnimationProvider() {
|
|
13
|
+
const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
|
|
14
|
+
|
|
15
|
+
const drivers = (this.drivers = []);
|
|
16
|
+
|
|
17
|
+
const RUNNER_STORAGE_KEY = "$$animationRunner";
|
|
18
|
+
const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
|
|
19
|
+
|
|
20
|
+
function setRunner(element, runner) {
|
|
21
|
+
element.data(RUNNER_STORAGE_KEY, runner);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function removeRunner(element) {
|
|
25
|
+
element.removeData(RUNNER_STORAGE_KEY);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getRunner(element) {
|
|
29
|
+
return element.data(RUNNER_STORAGE_KEY);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.$get = [
|
|
33
|
+
"$rootScope",
|
|
34
|
+
"$injector",
|
|
35
|
+
"$$AnimateRunner",
|
|
36
|
+
"$$rAFScheduler",
|
|
37
|
+
"$$animateCache",
|
|
38
|
+
function (
|
|
39
|
+
$rootScope,
|
|
40
|
+
$injector,
|
|
41
|
+
$$AnimateRunner,
|
|
42
|
+
$$rAFScheduler,
|
|
43
|
+
$$animateCache,
|
|
44
|
+
) {
|
|
45
|
+
const animationQueue = [];
|
|
46
|
+
const applyAnimationClasses = applyAnimationClassesFactory();
|
|
47
|
+
|
|
48
|
+
function sortAnimations(animations) {
|
|
49
|
+
const tree = { children: [] };
|
|
50
|
+
let i;
|
|
51
|
+
const lookup = new Map();
|
|
52
|
+
|
|
53
|
+
// this is done first beforehand so that the map
|
|
54
|
+
// is filled with a list of the elements that will be animated
|
|
55
|
+
// eslint-disable-next-line no-plusplus
|
|
56
|
+
for (i = 0; i < animations.length; i++) {
|
|
57
|
+
const animation = animations[i];
|
|
58
|
+
lookup.set(
|
|
59
|
+
animation.domNode,
|
|
60
|
+
(animations[i] = {
|
|
61
|
+
domNode: animation.domNode,
|
|
62
|
+
element: animation.element,
|
|
63
|
+
fn: animation.fn,
|
|
64
|
+
children: [],
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
for (i = 0; i < animations.length; i++) {
|
|
70
|
+
processNode(animations[i]);
|
|
71
|
+
}
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
return flatten(tree);
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
function processNode(entry) {
|
|
76
|
+
if (entry.processed) return entry;
|
|
77
|
+
entry.processed = true;
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
const elementNode = entry.domNode;
|
|
80
|
+
let { parentNode } = elementNode;
|
|
81
|
+
lookup.set(elementNode, entry);
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
83
|
+
let parentEntry;
|
|
84
|
+
while (parentNode) {
|
|
85
|
+
parentEntry = lookup.get(parentNode);
|
|
86
|
+
if (parentEntry) {
|
|
87
|
+
if (!parentEntry.processed) {
|
|
88
|
+
parentEntry = processNode(parentEntry);
|
|
93
89
|
}
|
|
94
|
-
|
|
90
|
+
break;
|
|
95
91
|
}
|
|
96
|
-
|
|
97
|
-
(parentEntry || tree).children.push(entry);
|
|
98
|
-
return entry;
|
|
92
|
+
parentNode = parentNode.parentNode;
|
|
99
93
|
}
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
let i;
|
|
95
|
+
(parentEntry || tree).children.push(entry);
|
|
96
|
+
return entry;
|
|
97
|
+
}
|
|
105
98
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
function flatten(tree) {
|
|
100
|
+
const result = [];
|
|
101
|
+
const queue = [];
|
|
102
|
+
let i;
|
|
109
103
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
for (i = 0; i < queue.length; i++) {
|
|
115
|
-
const entry = queue[i];
|
|
116
|
-
if (remainingLevelEntries <= 0) {
|
|
117
|
-
remainingLevelEntries = nextLevelEntries;
|
|
118
|
-
nextLevelEntries = 0;
|
|
119
|
-
result.push(row);
|
|
120
|
-
row = [];
|
|
121
|
-
}
|
|
122
|
-
row.push(entry);
|
|
123
|
-
entry.children.forEach((childEntry) => {
|
|
124
|
-
nextLevelEntries++;
|
|
125
|
-
queue.push(childEntry);
|
|
126
|
-
});
|
|
127
|
-
remainingLevelEntries--;
|
|
128
|
-
}
|
|
104
|
+
for (i = 0; i < tree.children.length; i++) {
|
|
105
|
+
queue.push(tree.children[i]);
|
|
106
|
+
}
|
|
129
107
|
|
|
130
|
-
|
|
108
|
+
let remainingLevelEntries = queue.length;
|
|
109
|
+
let nextLevelEntries = 0;
|
|
110
|
+
let row = [];
|
|
111
|
+
|
|
112
|
+
for (i = 0; i < queue.length; i++) {
|
|
113
|
+
const entry = queue[i];
|
|
114
|
+
if (remainingLevelEntries <= 0) {
|
|
115
|
+
remainingLevelEntries = nextLevelEntries;
|
|
116
|
+
nextLevelEntries = 0;
|
|
131
117
|
result.push(row);
|
|
118
|
+
row = [];
|
|
132
119
|
}
|
|
133
|
-
|
|
134
|
-
|
|
120
|
+
row.push(entry);
|
|
121
|
+
entry.children.forEach((childEntry) => {
|
|
122
|
+
nextLevelEntries++;
|
|
123
|
+
queue.push(childEntry);
|
|
124
|
+
});
|
|
125
|
+
remainingLevelEntries--;
|
|
135
126
|
}
|
|
136
|
-
}
|
|
137
127
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const isStructural = ["enter", "move", "leave"].indexOf(event) >= 0;
|
|
142
|
-
|
|
143
|
-
// there is no animation at the current moment, however
|
|
144
|
-
// these runner methods will get later updated with the
|
|
145
|
-
// methods leading into the driver's end/cancel methods
|
|
146
|
-
// for now they just stop the animation from starting
|
|
147
|
-
const runner = new $$AnimateRunner({
|
|
148
|
-
end() {
|
|
149
|
-
close();
|
|
150
|
-
},
|
|
151
|
-
cancel() {
|
|
152
|
-
close(true);
|
|
153
|
-
},
|
|
154
|
-
});
|
|
128
|
+
if (row.length) {
|
|
129
|
+
result.push(row);
|
|
130
|
+
}
|
|
155
131
|
|
|
156
|
-
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// TODO(matsko): document the signature in a better way
|
|
137
|
+
return function (element, event, options) {
|
|
138
|
+
options = prepareAnimationOptions(options);
|
|
139
|
+
const isStructural = ["enter", "move", "leave"].indexOf(event) >= 0;
|
|
140
|
+
|
|
141
|
+
// there is no animation at the current moment, however
|
|
142
|
+
// these runner methods will get later updated with the
|
|
143
|
+
// methods leading into the driver's end/cancel methods
|
|
144
|
+
// for now they just stop the animation from starting
|
|
145
|
+
const runner = new $$AnimateRunner({
|
|
146
|
+
end() {
|
|
157
147
|
close();
|
|
158
|
-
|
|
159
|
-
|
|
148
|
+
},
|
|
149
|
+
cancel() {
|
|
150
|
+
close(true);
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (!drivers.length) {
|
|
155
|
+
close();
|
|
156
|
+
return runner;
|
|
157
|
+
}
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
159
|
+
let classes = mergeClasses(
|
|
160
|
+
element.attr("class"),
|
|
161
|
+
mergeClasses(options.addClass, options.removeClass),
|
|
162
|
+
);
|
|
163
|
+
let { tempClasses } = options;
|
|
164
|
+
if (tempClasses) {
|
|
165
|
+
classes += ` ${tempClasses}`;
|
|
166
|
+
options.tempClasses = null;
|
|
167
|
+
}
|
|
170
168
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
if (isStructural) {
|
|
170
|
+
element.data(
|
|
171
|
+
PREPARE_CLASSES_KEY,
|
|
172
|
+
`ng-${event}${PREPARE_CLASS_SUFFIX}`,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
177
175
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
176
|
+
setRunner(element, runner);
|
|
177
|
+
|
|
178
|
+
animationQueue.push({
|
|
179
|
+
// this data is used by the postDigest code and passed into
|
|
180
|
+
// the driver step function
|
|
181
|
+
element,
|
|
182
|
+
classes,
|
|
183
|
+
event,
|
|
184
|
+
structural: isStructural,
|
|
185
|
+
options,
|
|
186
|
+
beforeStart,
|
|
187
|
+
close,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
element.on("$destroy", handleDestroyedElement);
|
|
191
|
+
|
|
192
|
+
// we only want there to be one function called within the post digest
|
|
193
|
+
// block. This way we can group animations for all the animations that
|
|
194
|
+
// were apart of the same postDigest flush call.
|
|
195
|
+
if (animationQueue.length > 1) return runner;
|
|
196
|
+
|
|
197
|
+
$rootScope.$$postDigest(() => {
|
|
198
|
+
const animations = [];
|
|
199
|
+
forEach(animationQueue, (entry) => {
|
|
200
|
+
// the element was destroyed early on which removed the runner
|
|
201
|
+
// form its storage. This means we can't animate this element
|
|
202
|
+
// at all and it already has been closed due to destruction.
|
|
203
|
+
if (getRunner(entry.element)) {
|
|
204
|
+
animations.push(entry);
|
|
205
|
+
} else {
|
|
206
|
+
entry.close();
|
|
207
|
+
}
|
|
190
208
|
});
|
|
191
209
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
// now any future animations will be in another postDigest
|
|
211
|
+
animationQueue.length = 0;
|
|
212
|
+
|
|
213
|
+
const groupedAnimations = groupAnimations(animations);
|
|
214
|
+
const toBeSortedAnimations = [];
|
|
215
|
+
|
|
216
|
+
forEach(groupedAnimations, (animationEntry) => {
|
|
217
|
+
const element = animationEntry.from
|
|
218
|
+
? animationEntry.from.element
|
|
219
|
+
: animationEntry.element;
|
|
220
|
+
let extraClasses = options.addClass;
|
|
221
|
+
|
|
222
|
+
extraClasses =
|
|
223
|
+
(extraClasses ? `${extraClasses} ` : "") + NG_ANIMATE_CLASSNAME;
|
|
224
|
+
const cacheKey = $$animateCache.cacheKey(
|
|
225
|
+
element[0],
|
|
226
|
+
animationEntry.event,
|
|
227
|
+
extraClasses,
|
|
228
|
+
options.removeClass,
|
|
229
|
+
);
|
|
211
230
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
options.removeClass,
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
toBeSortedAnimations.push({
|
|
234
|
-
element,
|
|
235
|
-
domNode: getDomNode(element),
|
|
236
|
-
fn: function triggerAnimationStart() {
|
|
237
|
-
let startAnimationFn;
|
|
238
|
-
const closeFn = animationEntry.close;
|
|
239
|
-
|
|
240
|
-
// in the event that we've cached the animation status for this element
|
|
241
|
-
// and it's in fact an invalid animation (something that has duration = 0)
|
|
242
|
-
// then we should skip all the heavy work from here on
|
|
243
|
-
if (
|
|
244
|
-
$$animateCache.containsCachedAnimationWithoutDuration(
|
|
245
|
-
cacheKey,
|
|
246
|
-
)
|
|
247
|
-
) {
|
|
248
|
-
closeFn();
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
231
|
+
toBeSortedAnimations.push({
|
|
232
|
+
element,
|
|
233
|
+
domNode: getDomNode(element),
|
|
234
|
+
fn: function triggerAnimationStart() {
|
|
235
|
+
let startAnimationFn;
|
|
236
|
+
const closeFn = animationEntry.close;
|
|
237
|
+
|
|
238
|
+
// in the event that we've cached the animation status for this element
|
|
239
|
+
// and it's in fact an invalid animation (something that has duration = 0)
|
|
240
|
+
// then we should skip all the heavy work from here on
|
|
241
|
+
if (
|
|
242
|
+
$$animateCache.containsCachedAnimationWithoutDuration(
|
|
243
|
+
cacheKey,
|
|
244
|
+
)
|
|
245
|
+
) {
|
|
246
|
+
closeFn();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
251
249
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
250
|
+
// it's important that we apply the `ng-animate` CSS class and the
|
|
251
|
+
// temporary classes before we do any driver invoking since these
|
|
252
|
+
// CSS classes may be required for proper CSS detection.
|
|
253
|
+
animationEntry.beforeStart();
|
|
254
|
+
|
|
255
|
+
// in the event that the element was removed before the digest runs or
|
|
256
|
+
// during the RAF sequencing then we should not trigger the animation.
|
|
257
|
+
const targetElement = animationEntry.anchors
|
|
258
|
+
? animationEntry.from.element || animationEntry.to.element
|
|
259
|
+
: animationEntry.element;
|
|
260
|
+
|
|
261
|
+
if (getRunner(targetElement)) {
|
|
262
|
+
const operation = invokeFirstDriver(animationEntry);
|
|
263
|
+
if (operation) {
|
|
264
|
+
startAnimationFn = operation.start;
|
|
268
265
|
}
|
|
266
|
+
}
|
|
269
267
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
});
|
|
268
|
+
if (!startAnimationFn) {
|
|
269
|
+
closeFn();
|
|
270
|
+
} else {
|
|
271
|
+
const animationRunner = startAnimationFn();
|
|
272
|
+
animationRunner.done((status) => {
|
|
273
|
+
closeFn(!status);
|
|
274
|
+
});
|
|
275
|
+
updateAnimationRunners(animationEntry, animationRunner);
|
|
276
|
+
}
|
|
277
|
+
},
|
|
281
278
|
});
|
|
279
|
+
});
|
|
282
280
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
281
|
+
// we need to sort each of the animations in order of parent to child
|
|
282
|
+
// relationships. This ensures that the child classes are applied at the
|
|
283
|
+
// right time.
|
|
284
|
+
const finalAnimations = sortAnimations(toBeSortedAnimations);
|
|
285
|
+
for (let i = 0; i < finalAnimations.length; i++) {
|
|
286
|
+
const innerArray = finalAnimations[i];
|
|
287
|
+
for (let j = 0; j < innerArray.length; j++) {
|
|
288
|
+
const entry = innerArray[j];
|
|
289
|
+
const { element } = entry;
|
|
290
|
+
|
|
291
|
+
// the RAFScheduler code only uses functions
|
|
292
|
+
finalAnimations[i][j] = entry.fn;
|
|
293
|
+
|
|
294
|
+
// the first row of elements shouldn't have a prepare-class added to them
|
|
295
|
+
// since the elements are at the top of the animation hierarchy and they
|
|
296
|
+
// will be applied without a RAF having to pass...
|
|
297
|
+
if (i === 0) {
|
|
298
|
+
element.removeData(PREPARE_CLASSES_KEY);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
303
301
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
302
|
+
const prepareClassName = element.data(PREPARE_CLASSES_KEY);
|
|
303
|
+
if (prepareClassName) {
|
|
304
|
+
element[0].classList.add(prepareClassName);
|
|
308
305
|
}
|
|
309
306
|
}
|
|
307
|
+
}
|
|
310
308
|
|
|
311
|
-
|
|
309
|
+
$$rAFScheduler(finalAnimations);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
return runner;
|
|
313
|
+
|
|
314
|
+
// TODO(matsko): change to reference nodes
|
|
315
|
+
function getAnchorNodes(node) {
|
|
316
|
+
const SELECTOR = `[${NG_ANIMATE_REF_ATTR}]`;
|
|
317
|
+
const items = node.hasAttribute(NG_ANIMATE_REF_ATTR)
|
|
318
|
+
? [node]
|
|
319
|
+
: node.querySelectorAll(SELECTOR);
|
|
320
|
+
const anchors = [];
|
|
321
|
+
forEach(items, (node) => {
|
|
322
|
+
const attr = node.getAttribute(NG_ANIMATE_REF_ATTR);
|
|
323
|
+
if (attr && attr.length) {
|
|
324
|
+
anchors.push(node);
|
|
325
|
+
}
|
|
312
326
|
});
|
|
327
|
+
return anchors;
|
|
328
|
+
}
|
|
313
329
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
330
|
+
function groupAnimations(animations) {
|
|
331
|
+
const preparedAnimations = [];
|
|
332
|
+
const refLookup = {};
|
|
333
|
+
forEach(animations, (animation, index) => {
|
|
334
|
+
const { element } = animation;
|
|
335
|
+
const node = getDomNode(element);
|
|
336
|
+
const { event } = animation;
|
|
337
|
+
const enterOrMove = ["enter", "move"].indexOf(event) >= 0;
|
|
338
|
+
const anchorNodes = animation.structural
|
|
339
|
+
? getAnchorNodes(node)
|
|
340
|
+
: [];
|
|
341
|
+
|
|
342
|
+
if (anchorNodes.length) {
|
|
343
|
+
const direction = enterOrMove ? "to" : "from";
|
|
344
|
+
|
|
345
|
+
forEach(anchorNodes, (anchor) => {
|
|
346
|
+
const key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
|
|
347
|
+
refLookup[key] = refLookup[key] || {};
|
|
348
|
+
refLookup[key][direction] = {
|
|
349
|
+
animationID: index,
|
|
350
|
+
element: jqLite(anchor),
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
preparedAnimations.push(animation);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
331
357
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
forEach(anchorNodes, (anchor) => {
|
|
348
|
-
const key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
|
|
349
|
-
refLookup[key] = refLookup[key] || {};
|
|
350
|
-
refLookup[key][direction] = {
|
|
351
|
-
animationID: index,
|
|
352
|
-
element: jqLite(anchor),
|
|
353
|
-
};
|
|
354
|
-
});
|
|
355
|
-
} else {
|
|
356
|
-
preparedAnimations.push(animation);
|
|
358
|
+
const usedIndicesLookup = {};
|
|
359
|
+
const anchorGroups = {};
|
|
360
|
+
Object.values(refLookup).forEach((operations) => {
|
|
361
|
+
const { from } = operations;
|
|
362
|
+
const { to } = operations;
|
|
363
|
+
|
|
364
|
+
if (!from || !to) {
|
|
365
|
+
// only one of these is set therefore we can't have an
|
|
366
|
+
// anchor animation since all three pieces are required
|
|
367
|
+
const index = from ? from.animationID : to.animationID;
|
|
368
|
+
const indexKey = index.toString();
|
|
369
|
+
if (!usedIndicesLookup[indexKey]) {
|
|
370
|
+
usedIndicesLookup[indexKey] = true;
|
|
371
|
+
preparedAnimations.push(animations[index]);
|
|
357
372
|
}
|
|
358
|
-
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
359
375
|
|
|
360
|
-
const
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
376
|
+
const fromAnimation = animations[from.animationID];
|
|
377
|
+
const toAnimation = animations[to.animationID];
|
|
378
|
+
const lookupKey = from.animationID.toString();
|
|
379
|
+
if (!anchorGroups[lookupKey]) {
|
|
380
|
+
const group = (anchorGroups[lookupKey] = {
|
|
381
|
+
structural: true,
|
|
382
|
+
beforeStart() {
|
|
383
|
+
fromAnimation.beforeStart();
|
|
384
|
+
toAnimation.beforeStart();
|
|
385
|
+
},
|
|
386
|
+
close() {
|
|
387
|
+
fromAnimation.close();
|
|
388
|
+
toAnimation.close();
|
|
389
|
+
},
|
|
390
|
+
classes: cssClassesIntersection(
|
|
391
|
+
fromAnimation.classes,
|
|
392
|
+
toAnimation.classes,
|
|
393
|
+
),
|
|
394
|
+
from: fromAnimation,
|
|
395
|
+
to: toAnimation,
|
|
396
|
+
anchors: [], // TODO(matsko): change to reference nodes
|
|
397
|
+
});
|
|
377
398
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
toAnimation.beforeStart();
|
|
387
|
-
},
|
|
388
|
-
close() {
|
|
389
|
-
fromAnimation.close();
|
|
390
|
-
toAnimation.close();
|
|
391
|
-
},
|
|
392
|
-
classes: cssClassesIntersection(
|
|
393
|
-
fromAnimation.classes,
|
|
394
|
-
toAnimation.classes,
|
|
395
|
-
),
|
|
396
|
-
from: fromAnimation,
|
|
397
|
-
to: toAnimation,
|
|
398
|
-
anchors: [], // TODO(matsko): change to reference nodes
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// the anchor animations require that the from and to elements both have at least
|
|
402
|
-
// one shared CSS class which effectively marries the two elements together to use
|
|
403
|
-
// the same animation driver and to properly sequence the anchor animation.
|
|
404
|
-
if (group.classes.length) {
|
|
405
|
-
preparedAnimations.push(group);
|
|
406
|
-
} else {
|
|
407
|
-
preparedAnimations.push(fromAnimation);
|
|
408
|
-
preparedAnimations.push(toAnimation);
|
|
409
|
-
}
|
|
399
|
+
// the anchor animations require that the from and to elements both have at least
|
|
400
|
+
// one shared CSS class which effectively marries the two elements together to use
|
|
401
|
+
// the same animation driver and to properly sequence the anchor animation.
|
|
402
|
+
if (group.classes.length) {
|
|
403
|
+
preparedAnimations.push(group);
|
|
404
|
+
} else {
|
|
405
|
+
preparedAnimations.push(fromAnimation);
|
|
406
|
+
preparedAnimations.push(toAnimation);
|
|
410
407
|
}
|
|
408
|
+
}
|
|
411
409
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
});
|
|
410
|
+
anchorGroups[lookupKey].anchors.push({
|
|
411
|
+
out: from.element,
|
|
412
|
+
in: to.element,
|
|
416
413
|
});
|
|
414
|
+
});
|
|
417
415
|
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
return preparedAnimations;
|
|
417
|
+
}
|
|
420
418
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
419
|
+
function cssClassesIntersection(a, b) {
|
|
420
|
+
a = a.split(" ");
|
|
421
|
+
b = b.split(" ");
|
|
422
|
+
const matches = [];
|
|
425
423
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
424
|
+
for (let i = 0; i < a.length; i++) {
|
|
425
|
+
const aa = a[i];
|
|
426
|
+
if (aa.substring(0, 3) === "ng-") continue;
|
|
429
427
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
428
|
+
for (let j = 0; j < b.length; j++) {
|
|
429
|
+
if (aa === b[j]) {
|
|
430
|
+
matches.push(aa);
|
|
431
|
+
break;
|
|
435
432
|
}
|
|
436
433
|
}
|
|
437
|
-
|
|
438
|
-
return matches.join(" ");
|
|
439
434
|
}
|
|
440
435
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
// may attempt more elements, but custom drivers are more particular
|
|
444
|
-
for (let i = drivers.length - 1; i >= 0; i--) {
|
|
445
|
-
const driverName = drivers[i];
|
|
446
|
-
const factory = $injector.get(driverName);
|
|
447
|
-
const driver = factory(animationDetails);
|
|
448
|
-
if (driver) {
|
|
449
|
-
return driver;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
436
|
+
return matches.join(" ");
|
|
437
|
+
}
|
|
453
438
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
439
|
+
function invokeFirstDriver(animationDetails) {
|
|
440
|
+
// we loop in reverse order since the more general drivers (like CSS and JS)
|
|
441
|
+
// may attempt more elements, but custom drivers are more particular
|
|
442
|
+
for (let i = drivers.length - 1; i >= 0; i--) {
|
|
443
|
+
const driverName = drivers[i];
|
|
444
|
+
const factory = $injector.get(driverName);
|
|
445
|
+
const driver = factory(animationDetails);
|
|
446
|
+
if (driver) {
|
|
447
|
+
return driver;
|
|
462
448
|
}
|
|
463
449
|
}
|
|
450
|
+
}
|
|
464
451
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
452
|
+
function beforeStart() {
|
|
453
|
+
tempClasses =
|
|
454
|
+
(tempClasses ? `${tempClasses} ` : "") + NG_ANIMATE_CLASSNAME;
|
|
455
|
+
element.className += ` ${tempClasses}`;
|
|
456
|
+
let prepareClassName = element.data(PREPARE_CLASSES_KEY);
|
|
457
|
+
if (prepareClassName) {
|
|
458
|
+
element[0].classList.remove(prepareClassName);
|
|
459
|
+
prepareClassName = null;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
472
462
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
463
|
+
function updateAnimationRunners(animation, newRunner) {
|
|
464
|
+
if (animation.from && animation.to) {
|
|
465
|
+
update(animation.from.element);
|
|
466
|
+
update(animation.to.element);
|
|
467
|
+
} else {
|
|
468
|
+
update(animation.element);
|
|
477
469
|
}
|
|
478
470
|
|
|
479
|
-
function
|
|
471
|
+
function update(element) {
|
|
480
472
|
const runner = getRunner(element);
|
|
481
|
-
if (runner
|
|
482
|
-
runner.end();
|
|
483
|
-
}
|
|
473
|
+
if (runner) runner.setHost(newRunner);
|
|
484
474
|
}
|
|
475
|
+
}
|
|
485
476
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
477
|
+
function handleDestroyedElement() {
|
|
478
|
+
const runner = getRunner(element);
|
|
479
|
+
if (runner && (event !== "leave" || !options.$$domOperationFired)) {
|
|
480
|
+
runner.end();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
489
483
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
484
|
+
function close(rejected) {
|
|
485
|
+
element.off("$destroy", handleDestroyedElement);
|
|
486
|
+
removeRunner(element);
|
|
493
487
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
.forEach((cls) => element[0].classList.remove(cls));
|
|
498
|
-
}
|
|
488
|
+
applyAnimationClasses(element, options);
|
|
489
|
+
applyAnimationStyles(element, options);
|
|
490
|
+
options.domOperation();
|
|
499
491
|
|
|
500
|
-
|
|
492
|
+
if (tempClasses) {
|
|
493
|
+
tempClasses
|
|
494
|
+
.split(" ")
|
|
495
|
+
.forEach((cls) => element[0].classList.remove(cls));
|
|
501
496
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
497
|
+
|
|
498
|
+
runner.complete(!rejected);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
},
|
|
502
|
+
];
|
|
503
|
+
}
|