The final position of the Angular increment animation does not hold

Is there a way to trigger an animation when the value of countAllOrders changes? Specifically, I am attempting to adjust the margin of a list using keyframes in an Angular animation. Here is my HTML code:

  <ul class="digits" [@ordersValue]="countAllOrders" #digits>
    <li>0</li>
    <li>1</li>
    <li>{{ countAllOrders }}</li>
  </ul>

The implementation of the animation is as follows:

  animations: [
    trigger('ordersValue', [
      transition(':increment', [
        animate('1s', keyframes([style({ marginTop: '-7em' })])),
      ]),
    ]),
  ],

The initial CSS of .digits sets margin-top:0em. During the animation, the desired effect works but instead of ending with a margin-top value of -7em, it finishes with 0em.

Based on some answers I found here, I attempted to use state:

trigger('ordersValue', [
  state(':increment', style({ marginTop: '-7em' })),
  transition(':increment', [
    style({ marginTop: '-7em' }),
    animate('1s', style('*')),
  ]),
]),

CSS:

.digits {
  list-style-type: none;
  margin-top: 0em;
  animation-duration: 1s;
  animation-timing-function: ease;
  animation-fill-mode: forwards;
}

However, that did not resolve the issue. Any suggestions on how to approach this problem?

Answer №1

Do you think it's necessary to include from marginTop: '0' and to marginTop: '-7em' in the keyframe?

If you need more information, check out this link: https://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp

To make adjustments, add animation-fill-mode:forwards; as the last line and remove infinite from the second-to-last line.

  position: relative;
  animation: mymove 5s;
  animation-fill-mode:forwards;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring methods for interacting with and controlling structural directives in e2e testing

Background: My goal is to permutation all potential configurations of an Angular2 screen for a specified route and capture screenshots using Protractor from the following link: http://www.protractortest.org/#/debugging. Problem: I am struggling to figure ...

Easily transferring sessionStorage values between components in Angular

I am looking for assistance on storing a user ID in sessionStorage and retrieving it in a blog component. Can anyone guide me on how to achieve this? LoginComponent.ts import { Component, OnInit } from '@angular/core'; import { Router, Activate ...

Having difficulty generating a footer for a page that includes a Material-UI Drawer component

Looking to create a standard full-width footer at the bottom of my page, I need help with the implementation. Utilizing the "Permanent drawer" from Material-UI Drawer for reference here. If you're interested in experimenting with it, CodeSandbox link ...

Alerting Users Before Navigating Away from an Angular Page

I am looking to implement a feature in my app that will display a warning message when attempting to close the tab, exit the page, or reload it. However, I am facing an issue where the warning message is displayed but the page still exits before I can resp ...

Is there a way to customize the navbar layout so that link 1 is aligned to the right side, link 2 is centered, and link 3 is positioned on the right?

I attempted to utilize the flex property and justify content, but unfortunately that did not yield the desired result. I experimented with the code provided below. The goal is to create a website layout with a logo at the top and a navigation bar directly ...

Stop the infiltration of emotions into your style

Utilizing the JsonForms React Component to dynamically generate an HTML form in my web application. The framework I am using handles all view rendering on the server side. To integrate this component, I compiled a small react component by running npm run b ...

Struggling to convert a JSON response into an object model using TypeScript in Angular?

I'm encountering a problem when trying to convert a JSON response into an object. All the properties of my object are being treated as strings, is that normal? Below is my AJAX request: public fetchSingle = (keys: any[]): Observable<Medal> =&g ...

Why is my column getting devoured even though it has custom content tailored to it?

In my layout, I have one column, one row, and three nested columns. Each column contains a custom-designed button instead of using the default Bootstrap button. However, there seems to be an issue where one of the columns is getting cut off. To better und ...

What is the reason for the additional space and irregular alignment of my divs when utilizing the 960 grid system?

One issue I'm facing is that elements within divs are aligning randomly without responding to any alignment tags. Additionally, some divs are creating extra space above or below their elements. I am using the 960 grid system and have not made any chan ...

Tips for sending data in Angular 8's Http GET method within a service class, especially when the backend requires a dictionary format

I am working on a C# backend with an HttpGet method that is expecting a dictionary as request parameters. public async Task<IActionResult> Search([BindRequired, FromQuery] IDictionary<string, object> pairs) Currently, my frontend is built in A ...

Setting up an image DIV for a dynamic overlay effect

Here is a JSFiddle that works correctly with fixed height and width: http://jsfiddle.net/69td39ha/2/. The animation activates correctly when hovered over. I attempted to adapt the above example to be responsive without fixed dimensions. However, I'm ...

Troubleshooting routing: The Location.path() function consistently returns an empty string

I stumbled upon this tutorial which seems to be the most up-to-date example for testing routing. I'm eager to incorporate mock components in my testing strategy eventually. Unfortunately, when trying out the provided plunker, I encountered some issues ...

Use PipeTransform to apply multiple filters simultaneously

Is it possible to apply multiple filters with PipeTransform? I attempted the following: posts; postss; transform(items: any[]): any[] { if (items && items.length) this.posts = items.filter(it => it.library = it.library ...

Bring the worth of node to angular universal

We are facing a challenge in our Angular Universal app where we need to transfer a value from node.js to Angular when running server-side. Our current solution involves the following code snippet in server.ts: const theValue: TheType = nodeLogicToRetrieve ...

Utilize ASP.NET Boilerplate Core and Angular on Microsoft Azure for seamless deployment

I am looking to deploy ASP.NET Boilerplate Core & Angular on Microsoft Azure. The current version of ASP.NET Boilerplate consists of two solutions (one for the backend and one for the frontend), so I need to deploy them on two separate AppServices along wi ...

Issues with alignment within Bootstrap grid system

I have three unique "cards" that I want to display horizontally and center on the page without using the bootstrap card class. Currently, I am attempting to assign each of them a width of .col-lg-4 within an outer div set to full width. However, they are s ...

Stop users from navigating back to specific routes by implementing route guards in Angular

I'm pondering whether it's possible to restrict users from revisiting certain routes Here's my dilemma: after a user logs in and follows the login/callback route for authentication, they can get stuck if they navigate back to that same rout ...

What method does the CSS standard dictate for measuring the width of an element?

In terms of measuring an element's width, Chrome appears to calculate it from the inner margin inclusive of padding. On the other hand, Firefox and IE determine the width of the box from the border, excluding padding but including the margin. Personal ...

Explore three stylish ways to showcase dynamic JavaScript content using CSS

Objective: For Value 1, the CSS class should be badge-primary For Value 2, the CSS class should be badge-secondary For all other values, use the CSS class badge-danger This functionality is implemented in the handleChange function. Issue: Current ...

Tips for showing that every field in a typed form group must be filled out

Starting from Angular 14, reactive forms are now strictly typed by default (Typed Forms). This new feature is quite convenient. I recently created a basic login form as shown below. form = this.fb.group({ username: ['', [Validators.required ...