2017-04-26 17:44:28 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
2020-05-19 19:08:49 +00:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-04-26 17:44:28 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {trigger} from '@angular/animations';
|
|
|
|
|
|
|
|
|
|
import {TriggerAst} from '../src/dsl/animation_ast';
|
|
|
|
|
import {buildAnimationAst} from '../src/dsl/animation_ast_builder';
|
|
|
|
|
import {AnimationTrigger, buildTrigger} from '../src/dsl/animation_trigger';
|
2021-07-04 08:57:55 +00:00
|
|
|
import {NoopAnimationStyleNormalizer} from '../src/dsl/style_normalization/animation_style_normalizer';
|
2022-02-08 00:03:51 +00:00
|
|
|
import {triggerParsingFailed} from '../src/error_helpers';
|
2022-02-12 22:32:03 +00:00
|
|
|
import {triggerParsingWarnings} from '../src/warning_helpers';
|
2017-08-15 23:11:11 +00:00
|
|
|
import {MockAnimationDriver} from '../testing/src/mock_animation_driver';
|
2017-04-26 17:44:28 +00:00
|
|
|
|
|
|
|
|
export function makeTrigger(
|
2024-01-18 18:38:04 +00:00
|
|
|
name: string,
|
|
|
|
|
steps: any,
|
|
|
|
|
skipErrors: boolean = false,
|
|
|
|
|
): AnimationTrigger {
|
2017-08-15 23:11:11 +00:00
|
|
|
const driver = new MockAnimationDriver();
|
2022-02-08 00:03:51 +00:00
|
|
|
const errors: Error[] = [];
|
2022-02-12 22:32:03 +00:00
|
|
|
const warnings: string[] = [];
|
2017-04-26 17:44:28 +00:00
|
|
|
const triggerData = trigger(name, steps);
|
2022-02-12 22:32:03 +00:00
|
|
|
const triggerAst = buildAnimationAst(driver, triggerData, errors, warnings) as TriggerAst;
|
2017-04-26 17:44:28 +00:00
|
|
|
if (!skipErrors && errors.length) {
|
2022-02-08 00:03:51 +00:00
|
|
|
throw triggerParsingFailed(name, errors);
|
2017-04-26 17:44:28 +00:00
|
|
|
}
|
2022-02-12 22:32:03 +00:00
|
|
|
if (warnings.length) {
|
|
|
|
|
triggerParsingWarnings(name, warnings);
|
|
|
|
|
}
|
2021-07-04 08:57:55 +00:00
|
|
|
return buildTrigger(name, triggerAst, new NoopAnimationStyleNormalizer());
|
2017-04-26 17:44:28 +00:00
|
|
|
}
|