Socket
Socket
Sign inDemoInstall

@angular/animations

Package Overview
Dependencies
4
Maintainers
2
Versions
752
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @angular/animations

Angular - animations integration with web-animations


Version published
Maintainers
2
Created

Package description

What is @angular/animations?

The @angular/animations package provides powerful animation capabilities and tools to Angular applications. It allows developers to define complex animations and transitions in a declarative manner, directly within their Angular components.

What are @angular/animations's main functionalities?

Trigger and state-based animations

This feature allows defining animations based on triggers and states. The example shows an animation trigger named 'openClose' with two states, 'open' and 'closed', and transitions between these states with different styles and durations.

import { trigger, state, style, animate, transition } from '@angular/animations';

@Component({
  selector: 'my-component',
  templateUrl: 'my-component.html',
  animations: [
    trigger('openClose', [
      state('open', style({
        height: '200px',
        opacity: 1,
        backgroundColor: 'yellow'
      })),
      state('closed', style({
        height: '100px',
        opacity: 0.5,
        backgroundColor: 'green'
      })),
      transition('open => closed', [
        animate('1s')
      ]),
      transition('closed => open', [
        animate('0.5s')
      ]),
    ]),
  ]
})
export class MyComponent {
  isOpen = true;

  toggle() {
    this.isOpen = !this.isOpen;
  }
}

Animation callbacks

Animation callbacks allow you to listen for when an animation starts and ends. In this example, the 'onAnimationEvent' method is called with the animation event, which includes the phase name ('start' or 'done').

import { trigger, state, style, animate, transition } from '@angular/animations';

@Component({
  selector: 'my-component',
  templateUrl: 'my-component.html',
  animations: [
    trigger('openClose', [
      transition('open => closed', [
        animate('1s', style({ opacity: 0 }))
      ]),
    ]),
  ]
})
export class MyComponent {
  animationStatus = 'ready';

  onAnimationEvent(event: AnimationEvent) {
    this.animationStatus = event.phaseName;
  }
}

Reusable animations

Reusable animations allow you to define an animation once and reuse it in different components or triggers. The example defines a 'fadeInAnimation' and uses it in a component with the 'fadeIn' trigger.

import { animation, useAnimation, transition, trigger } from '@angular/animations';

export const fadeInAnimation = animation([ animate('100ms ease-in', style({ opacity: 1 })) ]);

@Component({
  selector: 'my-component',
  templateUrl: 'my-component.html',
  animations: [
    trigger('fadeIn', [
      transition(':enter', useAnimation(fadeInAnimation))
    ])
  ]
})
export class MyComponent {}

Other packages similar to @angular/animations

Changelog

Source

17.3.0 (2024-03-13)

compiler

| Commit | Type | Description | | -- | -- | -- | | 1a6beae8a2 | feat | Enable template pipeline by default. (#54571) | | f386a04c9d | fix | handle two-way bindings to signal-based template variables in instruction generation (#54714) | | 1f129f114e | fix | not catching for loop empty tracking expressions (#54772) |

compiler-cli

| Commit | Type | Description | | -- | -- | -- | | 12dc4d074e | fix | account for as expression in docs extraction (#54414) | | da7fbb40f0 | fix | detect when the linker is working in unpublished angular and widen supported versions (#54439) | | 492e03f699 | fix | flag two-way bindings to non-signal values in templates (#54714) | | 5afa4f0ec1 | fix | support ModuleWithProviders literal detection with typeof (#54650) |

core

| Commit | Type | Description | | -- | -- | -- | | 331b16efd2 | feat | add API to inject attributes on the host node (#54604) | | fb540e169a | feat | add migration for invalid two-way bindings (#54630) | | c687b8f453 | feat | expose new output() API (#54650) | | c809069f21 | feat | introduce outputFromObservable() interop function (#54650) | | aff65fd1f4 | feat | introduce outputToObservable interop helper (#54650) | | 974958913c | feat | support TypeScript 5.4 (#54414) | | 39a50f9a8d | fix | ensure all initializer functions run in an injection context (#54761) | | 243ccce624 | fix | exclude class attribute intended for projection matching from directive matching (#54800) | | 2909e9817d | fix | prevent infinite loops in clobbered elements check (#54425) | | 7243c704cf | fix | return a readonly signal on asReadonly. (#54706) | | bb35414a38 | perf | speed up retrieval of DestroyRef in EventEmitter (#54748) |

http

| Commit | Type | Description | | -- | -- | -- | | 8d37ed035c | fix | exclude caching for authenticated HTTP requests (#54746) |

router

| Commit | Type | Description | | -- | -- | -- | | c1c7384e02 | feat | Add reusable types for router guards (#54580) | | 7225485311 | fix | Navigations triggered by cancellation events should cancel previous navigation (#54710) |

<!-- CHANGELOG SPLIT MARKER -->

<a name="17.2.4"></a>

Readme

Source

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT

FAQs

Last updated on 13 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc