I'm using NativeScript with Angular 5.
"tns-core-modules": "~3.4.0",
"nativescript-angular": "~5.2.0",
"@angular/animations": "~5.2.0",
And I'm trying to get animations to work, but I can't get anything to happen at all. Not even any errors.
Here's how my app is laid out:
app.module:
@NgModule({
bootstrap: [
AppComponent
],
imports: [
CoreModule,
AppRoutingModule
],
declarations: [
AppComponent
]
})
That imports CoreModule which has the Animations import:
const MODULES: any[] = [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
NativeScriptAnimationsModule
];
@NgModule({
imports: [
...MODULES,
All of the rest of my modules are lazy loaded. For example my NotificationsModule looks like:
@NgModule({
imports: [
SharedModule,
NotificationsRoutingModule
And SharedModule has:
imports: [
NativeScriptCommonModule,
NativeScriptModule,
NativeScriptRouterModule,
NativeScriptFormsModule,
TNSFontIconModule,
],
Now in my notifications.component.html:
<Label [@mystate]="'in'"
And in the ts file:
animations: [
trigger('mystate', [
state('in', style({
'opacity': 1,
transform: 'scale(1) rotate(0)'
})),
state('void', style({
'opacity': 0,
transform: 'scale(0) rotate(-1300)'
})),
// 'after a delay of 1000ms, show an animation with a duration of 2300ms'
transition('void => *', [animate('2300ms 1000ms ease-out')])
]),
So this label should do a bunch of rotating as soon as the page loads. But nothing happens whatsoever. Is there something I'm missing?
To add more to this, I've tried other animations for entering and leaving and I can't get them to trigger either:
trigger('visibilityChanged', [
transition(':enter', [
style({ opacity: 0, transform: 'translateX(-40px)' }),
animate(600, style({ opacity: 1, transform: 'translateX(0)' }))
]),
transition(':leave', [
style({ opacity: 1, transform: 'translateX(0)' }),
animate(600, style({ opacity: 0, transform: 'translateX(-40px)'
}))
])
])
Html:
<StackLayout [@visibilityChanged] *ngIf="shouldBeVisible" row="1" colSpan="3" class="dropdown-wrapper m-t-4">
<Label text="test"></Label>
</StackLayout>