angular-animations

Angular Animations : How to bind animation trigger name dynamically in the template?

心不动则不痛 提交于 2019-12-01 14:23:26
I would like to know if there is a way to bind the animation trigger name dynamically in the template. Here is the div to animate in the template app.component.html : <div [@animationTriggerName]> ... </div> Here is the app.module.ts : ... @NgModule({ imports: [...], declarations: [ ..., AnimationTriggerNameDirective ], bootstrap: [...] }) And here is the app.component.ts : @Component({ ... }) export class AppComponent { ... animationTriggerName = 'slideInOut'; } @Directive({ selector: '[animationTriggerName]' }) export class AnimationTriggerNameDirective { @Input() animationTriggerName:

Repeat animation angular 4

醉酒当歌 提交于 2019-11-30 04:42:31
问题 I created the following animation: fade.animation.ts: import { Component } from '@angular/core'; import { trigger, state, animate, query, transition, style, stagger } from '@angular/animations'; export let fade = trigger('fade', [ state('void', style({ opacity: 0 })), transition(':enter, :leave', [ animate(2000) ]) ]); I'm using in the next component: <div id="mpl_loader" class="divCabeceraTitulo"> <div class="lineaTitulo"> <div class="logoMinisterio" [@fade]> <img src="assets/imagenes

Angular (4, 5, 6, 7) - Simple example of slide in out animation on ngIf

寵の児 提交于 2019-11-29 20:27:14
What is the bare minimum and Angular4 's native way to slide in and slide out a container element? e.g. <div ngIf="show"> <!-- Content --> </div> Slide In Content (from top to down just like jQuery. slideDown ()) when show turns to true . Slide Out Content (suitably with ease-out effect) when show turns to false . First some code, then the explanaition. The official docs describing this are here . import { trigger, transition, animate, style } from '@angular/animations' @Component({ ... animations: [ trigger('slideInOut', [ transition(':enter', [ style({transform: 'translateY(-100%)'}),

What's the difference between BrowserAnimationsModule and NoopAnimationsModule?

我是研究僧i 提交于 2019-11-28 08:51:58
With the new Angular-Material release, you need to add a module for Angular-Animations. You can choose between two BrowserAnimationsModule and NoopAnimationsModule. The official guide states: Some Material components depend on the Angular animations module in order to be able to do more advanced transitions. If you want these animations to work in your app, you have to install the @angular/animations module and include the BrowserAnimationsModule in your app. npm install --save @angular/animations import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; @NgModule({ ...

Angular 4 - Scroll Animation

夙愿已清 提交于 2019-11-28 05:23:58
I'm creating a webpage having full page width/height div's. While scrolling down I've two types of methods. Scroll on Click //HTML <a (click)="goToDiv('about')"></a> //JS goToDiv(id) { let element = document.querySelector("#"+id); element.scrollIntoView(element); } Scroll on HostListener @HostListener("window:scroll", ['$event']) onWindowScroll($event: any): void { this.topOffSet = window.pageYOffset; //window.scrollTo(0, this.topOffSet+662); } 1. How to add a scrolling animation effects? Just like : $('.scroll').on('click', function(e) { $('html, body').animate({ scrollTop: $(window).height()

How can I animate *ngFor in Angular?

橙三吉。 提交于 2019-11-27 23:00:49
I need to animate an ngFor list as it is populated and shown. Each element should have a transition, let's say something like this . How can I do that? Günter Zöchbauer It has a few issues because ngFor does a few redundant add/removes which cause items to be animated which shouldn't: import {Component} from 'angular2/core'; import { Component, Directive, OnDestroy, Input } from 'angular2/core'; @Component({ selector: 'my-app', template: `<div (click)="$event.preventDefault()"> <button type="button" (click)="pushItem()">Push</button> <button type="button" (click)="removeItemLast()">Remove Last

Parameter in to Animation Angular2

こ雲淡風輕ζ 提交于 2019-11-27 04:03:38
I'm trying to make a simple animation like the simple jQuery below animate({'left' : left_indent}) I'm using the Angular2 Animations but the problem is how do I pass the left_indent parameter outside my Component Class in to the animation trigger? animations: [ trigger('flyInOut', [ state('for', style({ left: this.left_indent, })), transition('* => for', [ animate(2000, keyframes([ style({ opacity: 1, transform: 'translateX(0)', offset: 0 }), style({ opacity: 1, transform: 'translateX(-300px)', offset: 0.5 }), ])) ]), ]) ] Now it's possible. animations: [ trigger('flyInOut', [ state('for',

What's the difference between BrowserAnimationsModule and NoopAnimationsModule?

拜拜、爱过 提交于 2019-11-27 02:29:06
问题 With the new Angular-Material release, you need to add a module for Angular-Animations. You can choose between two BrowserAnimationsModule and NoopAnimationsModule. The official guide states: Some Material components depend on the Angular animations module in order to be able to do more advanced transitions. If you want these animations to work in your app, you have to install the @angular/animations module and include the BrowserAnimationsModule in your app. npm install --save @angular

Angular 4 - Scroll Animation

半城伤御伤魂 提交于 2019-11-27 00:51:05
问题 I'm creating a webpage having full page width/height div's. While scrolling down I've two types of methods. Scroll on Click //HTML <a (click)="goToDiv('about')"></a> //JS goToDiv(id) { let element = document.querySelector("#"+id); element.scrollIntoView(element); } Scroll on HostListener @HostListener("window:scroll", ['$event']) onWindowScroll($event: any): void { this.topOffSet = window.pageYOffset; //window.scrollTo(0, this.topOffSet+662); } 1. How to add a scrolling animation effects?

Angular 2 “slide in animation” of a routed component

早过忘川 提交于 2019-11-26 16:29:49
问题 let's say I have 2 routed components and two Routerlinks in the fixed navbar to route them. I want them to slide in from the right when I click the Routerlinks. I don't want to offset the component with css and use a timeout function to change the css class to let it slide in (e.g. with ngStyle or ngClass). are there any more elegant ways do achieve that in Angular 2? Thanks! 回答1: With Angular 4.1 it is now possible to create specific route animations. This is different from triggering an