Issue with Angular 2 animations when using ngFor directive

I recently delved into the world of Angular 2 and TypeScript. Everything was going smoothly until I encountered an issue with Angular 2 animations. While they are generally easy to work with, I have stumbled upon a bug that is really starting to frustrate me.

To demonstrate what's happening, you can check out this Plunker link: http://plnkr.co/edit/0YsCgD0yUiIqIrTyuA5s?p=preview

The problem arises when removing an element from the todo list - instead of removing just the targeted element, all elements disappear. Despite still being present in the JavaScript logic, Angular fails to display them correctly. The animation runs on every element rather than just the selected one based on its index.

Below is the snippet of the specific animation causing issues:

    trigger('taskState', [

        state('void', style({
            opacity: 0,
            transform: 'translateX(50px)'
        })),
        transition('void => *', [
            animate('0.2s ease-out')
        ]),
        transition('* => void', [
            style({
                transform: 'scale(0)',
                height: 0
            }),
            animate('0.2s ease-in-out')
        ]),

        state('undone', style({ transform: 'scale(1)' })),
        state('done', style({ transform: 'scale(0.975)', opacity: '0.5' })),
        transition('undone <=> done', [
            animate('50ms ease-in-out')
        ])

    ])

Answer №1

The solution to this question has been implemented in the latest updates of Angular. If you are facing a similar issue, simply upgrade your Angular version.

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

The function maybeStripe.apply is not defined

Greetings, Encountering a Stripe error in Gatsby upon page load Error: Uncaught (in promise) TypeError: maybeStripe.apply is not a function import React, { useEffect, useState } from 'react'; import { loadStripe } from '@stripe/str ...

Why does babel-node encounter a "module not found" error when the ".js" extension is not included?

Why is babel-node not importing without the ".js" extension? I have "type": "module" in my package.json import example from "./src/example.js"; works fine import example from "./src/example"; does not work --es-module-specifier-resolution=node only works ...

In Node.js, use the `[]` operator to select elements from an array of strings without including

In my situation, I am working with an array of strings which can sometimes be an array containing only one string. The issue is that when this happens, using array[0] to retrieve the value does not return the entire string but rather just the first charact ...

Is there a way to retrieve a JSON result from an API call using jQuery (or plain JavaScript) without relying on Ajax?

As someone new to JS and jQuery, I am working on building a key-value map from an API call that returns an array of key-value pairs. [{"key":"191","value":244}, ... , {"key":"920","value":130}] I have created the following ajax code in my attempt to achi ...

A problem arises in Next.js when CSS is not rendering properly during Server Side Rendering

After creating my next.js application using the command npx create-next-app, I realized that the styles from the imported .css files are rendering correctly on Client Side Render but not on Server Side Render. The Next.js documentation states that importe ...

Tips on adjusting the pixel dimensions of an image using a file object

Within a form on our website, users have the ability to upload an image file. To ensure quality control, I've set up validation to confirm that the uploaded file is either an image or gif format. In addition to this, I'm looking for a solution th ...

Column Arrangements in a Table

Is there a method to insert a new column into a table using the jQuery plugin DataTables? ...

Adjust counter to allocate points based on team in Vue.js

Currently, I am tackling a Vue.js 3 school assignment that involves a dynamic number of teams competing in a football championship. The team data is stored in a JSON format and accessed via an API. The task at hand requires selecting two teams - one repres ...

Customize the default directory for local node modules installation in node.js using npm

If I prefer not to have my local (per project) packages installed in the node_modules directory, but rather in a directory named sources/node_modules, is there a way to override this like you can with bower? In bower, you specify the location using a .bow ...

What is the best way to create animations using a large sprite on iOS?

Currently, I am working on creating an animated infographic in iOS that involves approximately 140 images, each sized at 900x700 pixels. I have tried using CALayer with individual images as well as a spritesheet approach, but both methods result in lengt ...

Iframes are not compatible with JQuery UI dialogs

After attempting to open a URL within an Iframe in a JQuery dialog box, I encountered the following issue: Here is the code snippet that I used: http://pastebin.com/Wqf0mGhZ I am looking for a solution to make sure that the dialog displays all of the con ...

Utilize the JavaScript Email Error Box on different components

On my website, I have implemented a login system using LocalStorage and would like to incorporate an error message feature for incorrect entries. Since I already have assistance for handling email errors on another page, I am interested in applying that sa ...

Transforming jquery code into angularjsAre you looking to migrate your

I am currently struggling with converting a jQuery function into an AngularJS function. Here is the specific code snippet: $('p').each(function() { $(this).html($(this).text().split(/([\.\?!])(?= )/).map( function(v){return '< ...

Utilizing AngularJS to incorporate a global scope function within another function

I have a specific AngularJS function named editlocation that triggers a Modal window to edit three data points. Following this process, I aim to execute plotmarkers, which is utilized in another scenario of an ng-click. Despite attempting different approa ...

When building websites, pages, or applications with React, how do you determine the best choice between JavaScript, TypeScript, or JavaScriptXML?

After completing my portfolio and an eCommerce website design using Figma, I started learning React and Tailwind with Vite. I'm comfortable with basic JavaScript but now I want to understand the differences between .js, .jsx, and .ts files when workin ...

Trouble updating page title in UI-Router

After trying to modify the page title in my Angular app using UI Router, I came across a demo that worked perfectly. You can check it out here. However, when I attempted to replicate the same demonstration, it did not work for me. I need to investigate wh ...

Vue modal fails to display when triggered by a specific query parameter

I've encountered an interesting challenge with my Vue.js app. Currently, the modal is displayed correctly when a button is clicked using the show() method: <script> export default { methods: { show() { console.log("showing modal ...

A variable must be defined within a specific block in order to be recognized

In an effort to enhance my code within a passport function, I am looking to pull values from a mongodb Database rather than from an array. The initial functioning code appeared as follows: passport.use( new LocalStrategy( { usernameField: ...

Redux application is not functioning properly

I followed the official documentation to create a Redux app at http://redux.js.org/docs/basics/ but it's not working as expected. I have organized my code into four files: store, reducers, actions, and build. actions.js: export const ADD_TODO = &apo ...

Creating a complete webpage using HTML

Is there a method to load an HTML file and execute the embedded javascript to create a complete HTML page programmatically similar to how browsers do? Edit 1 - I am working on an application where I need to extract data from an HTML page on a remote websi ...