MCPcopy
hub / github.com/angular/angular / define

Method define

adev/src/app/features/home/animation/animation.ts:96–137  ·  view source on GitHub ↗

* Define the animation. * * @param definition Definition (i.e. `AnimationRule` array) * @returns The animation

(definition: AnimationDefinition)

Source from the content-addressed store, hash-verified

94 * @returns The animation
95 */
96 define(definition: AnimationDefinition) {
97 this.reset();
98 this.extractObjectsAndValidateRules(definition);
99
100 // Parse the rules.
101 // IMPORTANT: Parsed rules use milliseconds instead of seconds.
102 this.rules = definition
103 .sort((a, b) => getStartTime(a) - getStartTime(b))
104 .map((rule) => {
105 if (rule.timeframe) {
106 const from: ParsedStyles = {};
107 const to: ParsedStyles = {};
108
109 for (const [prop, val] of Object.entries(rule.from)) {
110 from[prop] = cssValueParser(val);
111 }
112 for (const [prop, val] of Object.entries(rule.to)) {
113 to[prop] = cssValueParser(val);
114 }
115 // Convert to milliseconds.
116 const msTimeframe = rule.timeframe.map((t) => t * MS) as [number, number];
117
118 return {...rule, from, to, timeframe: msTimeframe};
119 } else {
120 const styles: ParsedStyles = {};
121
122 for (const [prop, val] of Object.entries(rule.styles)) {
123 styles[prop] = cssValueParser(val);
124 }
125 // Convert to milliseconds.
126 const msAt = rule.at * MS;
127
128 return {...rule, styles, at: msAt};
129 }
130 });
131
132 // Calculate the duration of the animation.
133 // IMPORTANT: Use parsed rules with milliseconds.
134 this._duration = Math.max(...this.rules.map((r) => getEndTime(r)));
135
136 return this;
137 }
138
139 /** Play the animation. */
140 play() {

Callers 14

slots_spec.tsFile · 0.80
constructorMethod · 0.80
initAnimationMethod · 0.80
defineFnFunction · 0.80
animation.spec.tsFile · 0.80
angularComponentFunction · 0.80

Calls 8

resetMethod · 0.95
cssValueParserFunction · 0.90
getStartTimeFunction · 0.85
getEndTimeFunction · 0.85
mapMethod · 0.80
entriesMethod · 0.45
maxMethod · 0.45

Tested by 1

defineFnFunction · 0.64