-
Notifications
You must be signed in to change notification settings - Fork 20
/
transition-data.js
51 lines (42 loc) · 1.36 KB
/
transition-data.js
1
2
3
4
5
6
7
8
9
10
11
12
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
import Ember from 'ember';
import performanceNow from '../utils/performance-now';
import RenderData from './render-data';
// allow compatibility with IE8 via Ember's create polyfill
// jscs:disable disallowDirectPropertyAccess
const create = Object.create || Ember.create;
// jscs:enable disallowDirectPropertyAccess
function TransitionData(args) {
this._super$constructor(...arguments);
this.destURL = args.destURL;
this.destRoute = args.destRoute;
this.routes = [];
}
function t() {
return performanceNow();
}
let prototype = TransitionData.prototype = create(RenderData.prototype);
prototype.constructor = TransitionData;
prototype._super$constructor = RenderData;
prototype.activateRoute = function activateRoute(route) {
let startTime = t();
let r = {
name: route.routeName,
debugContainerKey: route._debugContainerKey,
startTime,
views: []
};
this.routes.push(r);
if (route.routeName.indexOf('loading') < 0 || !this._lastActivatedRoute) {
this._lastActivatedRoute = r;
}
};
prototype.routeFinishedSetup = function routeFinishedSetup(route) {
let endTime = t();
let [r] = this.routes.filter((r) => r.name === route.routeName);
r.endTime = endTime;
r.elapsedTime = r.endTime - r.startTime;
};
prototype._viewAdded = function _viewAdded(view, index) {
this._lastActivatedRoute.views.push(index);
};
export default TransitionData;