本文整理汇总了TypeScript中@angular/animations.state函数的典型用法代码示例。如果您正苦于以下问题:TypeScript state函数的具体用法?TypeScript state怎么用?TypeScript state使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了state函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: makeEngine
() => {
const engine = makeEngine();
const trig = trigger('something', [
state('x', style({opacity: 0})),
state('y', style({opacity: .5})),
state('z', style({opacity: 1})),
transition('* => *', animate(1000)),
]);
registerTrigger(element, engine, trig);
setProperty(element, engine, trig.name, 'x');
setProperty(element, engine, trig.name, 'y');
engine.flush();
expect(parseFloat(element.style.opacity)).not.toEqual(.5);
const player1 = engine.players[0];
setProperty(element, engine, trig.name, 'z');
engine.flush();
const player2 = engine.players[0];
expect(parseFloat(element.style.opacity)).not.toEqual(.5);
player2.finish();
expect(parseFloat(element.style.opacity)).toEqual(1);
player1.finish();
expect(parseFloat(element.style.opacity)).toEqual(1);
});
示例2: it
it('should cancel all existing players if a removal animation is set to occur', () => {
const engine = makeEngine();
const trig = trigger('something', [
state('m', style({opacity: 0})), state('n', style({opacity: 1})),
transition('* => *', animate(1000))
]);
registerTrigger(element, engine, trig);
setProperty(element, engine, trig.name, 'm');
setProperty(element, engine, trig.name, 'n');
engine.flush();
let doneCount = 0;
function doneCallback() { doneCount++; }
const player1 = engine.players[0];
player1.onDone(doneCallback);
expect(doneCount).toEqual(0);
setProperty(element, engine, trig.name, 'void');
engine.flush();
expect(doneCount).toEqual(1);
});
示例3: slideFromUp
export function slideFromUp() {
return trigger('routerTransition', [
state('void', style({ 'margin-top': '10px', opacity: '0' })),
state('*', style({ 'margin-top': '0px', opacity: '1' })),
transition(':enter', [
animate('0.3s ease-out', style({ opacity: '1', 'margin-top': '0px' }))
])
]);
}
示例4: slideFromBottom
export function slideFromBottom() {
return trigger('routerTransition', [
state('void', style({ 'padding-top': '20px', opacity: '0' })),
state('*', style({ 'padding-top': '0px', opacity: '1' })),
transition(':enter', [
animate('0.33s ease-out', style({ opacity: '1', 'padding-top': '0px' }))
])
]);
}
示例5: it
it('should construct a trigger based on the states and transition data', () => {
const result = makeTrigger('name', [
state('on', style({width: 0})), state('off', style({width: 100})),
transition('on => off', animate(1000)), transition('off => on', animate(1000))
]);
expect(result.states).toEqual({'on': {width: 0}, 'off': {width: 100}});
expect(result.transitionFactories.length).toEqual(2);
});
示例6: fadeInAnimation
function fadeInAnimation() {
return trigger('routerTransition', [
state('void', style({position:'fixed', width:'100%'}) ),
state('*', style({position:'fixed', width:'100%'}) ),
transition(':enter', [
style({opacity: 0}),
animate('1.5s', style({opacity: 1}))
]),
]);
}
示例7: visibility
export function visibility() {
return trigger('visibility', [
state('shown', style({
transform: 'scale(1.0)',
opacity: 1
})),
state('hidden', style({
transform: 'scale(0.5)',
opacity: 0
})),
transition('* => *', animate('0.5s ease-in-out'))
]);
}
示例8: flip
export function flip(name = 'flip', first = true, duration = 350, easing = 'ease-in-out') {
const timings = `${duration}ms ${easing}`;
return trigger(name, [
state(first ? 'first' : 'second', style({ transform: `rotateY(${first ? 360 : 0}deg)`, display: 'block' })),
state(first ? 'second' : 'first', style({ transform: `rotateY(180deg)`, display: 'none' })),
transition(':enter', animate(0)),
transition('* => *', animate(`${duration}ms ${easing}`)),
transition(
first ? 'second => first' : 'first => second',
animate(timings, keyframes([style({ display: 'none', offset: 0 }), style({ display: 'block', offset: 0.2 })])),
),
]);
}