Before version 4.2 (in RC for the moment), for a zoom animation, I used to have the following code:
export const magnifyAnimation = trigger('magnify', [
state('default', style({
'transform': 'scale(1)'
})),
state('magnified', style({
'transform': 'scale(1.3)'
})),
transition('default <=> magnified', [
animate('430ms ease-out')
])
]);
Now, since 4.2 supports input params (waited a long time for this), I'm going with this:
component code:
<button
[@magnify]="{ value: state, params: { scaleFactor: '1.3' }}"
(mouseenter)="state = 'magnified'"
(mouseleave)="state = 'default'">
Hover me
</button>
and the animation code changed to this:
const zoomEffect = animation([
animate('430ms ease-out', style({
'transform': 'scale({{scaleFactor}})'
}))
], { params: { scaleFactor: '1' } });
export const magnifyAnimation = trigger('magnify', [
transition('default => magnified', useAnimation(zoomEffect), { params: { scaleFactor: '1.3' } }),
transition('magnified => default', useAnimation(zoomEffect), { params: { scaleFactor: '1' } })
]);
BUT, without having styles defined in states in the animation code, after the animation finishes, the element (button in this case) always jumps to it's natural size. And I don't know of a way to specify the input param in the state() code block.
I've also tried this:
state('magnified', style({
'transform': '*'
}))
I was hoping it would keep whatever value the transformation had at the end of the animation, but it doesn't accomplish anything...