ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - DerStimmler/ngx-easy-view-transitions: Angular library for easier use of the View Transitions API
Angular library for easier use of the View Transitions API - DerStimmler/ngx-easy-view-transitions
Visit Site

GitHub - DerStimmler/ngx-easy-view-transitions: Angular library for easier use of the View Transitions API

GitHub - DerStimmler/ngx-easy-view-transitions: Angular library for easier use of the View Transitions API

ngx-easy-view-transitions

npm version npm downloads build GitHub license

Angular library for easier use of the View Transitions API

Demo

https://derstimmler.github.io/ngx-easy-view-transitions/

Installation

Available on npm.

npm install ngx-easy-view-transitions

You have to enable Angulars built-in view transitions in the Router using the withViewTransitions() function.

bootstrapApplication(AppComponent,
  {
    providers: [
      provideRouter(appRoutes, withViewTransitions())
    ]
  }
);

Usage

Morph elements

To morph an element during navigation from the old to the new state use the transitionName directive and provide the same name on both pages.

import { TransitionNameDirective } from 'ngx-easy-view-transitions';

users.component.html

<img transitionName="profile-picture" src="...">

user.component.html

<img transitionName="profile-picture" src="...">

Note that each transitionName must be unique for a page.

Customize animations

Instead of morphing an element, you can provide custom animations for entering and leaving the view using the inAnimation and outAnimation inputs. There are two ways to provide a custom animations: As CSS @keyframes rule or Keyframe array.

Using CSS @keyframes

You can simply use a CSS @keyframes rule from your CSS:

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
inAnimation = { keyframeName: 'fadeIn', duration: 600 };
outAnimation = { keyframeName: 'fadeIn', duration: 600, reverse: true };
<img transitionName="profile-picture" [inAnimation]="inAnimation" [outAnimation]="outAnimation" src="...">

Using Keyframe array

When you want to use typed objects instead of CSS you can provide a Keyframe array:

const fadeIn: Keyframe[] = [
  {
    opacity: 0,
    offset: 0,
  },
  {
    opacity: 1,
    offset: 1,
  },
];
inAnimation = { keyframes: fadeIn, duration: 600 };
outAnimation = { keyframes: fadeIn, duration: 600, reverse: true };
<img transitionName="profile-picture" [inAnimation]="inAnimation" [outAnimation]="outAnimation" src="...">

Built-In animations

To start faster there are some built-in animations available under DefaultTransitions.*.

import { DefaultTransitions } from 'ngx-easy-view-transitions';

inAnimation = { keyframes: DefaultTransitions.fadeInUp, duration: 600 };

You can see them in the demo and here.

Exclude element from view transitions

When you want to exclude an element form view transitions you can add the noTransition directive.

import { NoTransitionDirective } from 'ngx-easy-view-transitions';
<img noTransition src="...">

Configure default transition

By default View Transitions API will perform a cross-fade animation on all elements. But you can also provide your own in and out animations by adding the provideDefaultViewTransition() provider function.

In the following example the default animation gets disabled:

bootstrapApplication(AppComponent,
  {
    providers: [
      provideRouter(appRoutes, withViewTransitions()),
      provideDefaultViewTransition(
        { keyframes: DefaultTransitions.none, duration: 0 },
        { keyframes: DefaultTransitions.none, duration: 0 }
      )
    ]
  }
);

Development

Install dependencies with: pnpm install

Run pnpm demo to run the demo app on a local development server. You can access it on http://localhost:4200.

Run pnpm test to test all projects.

Run pnpm lint to lint all projects.

Run pnpm build to build all projects. You can find the output under /dist.

Since it's a nx workspace you can use the common nx commands for everything else.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory