What could be causing the div to not respond to ngAnimate?

Recently, I encountered an issue with adding animations to a list of <div>'s in my webapp. After incorporating ngAnimate into the app.js file and including ng-animate="'animate'" in the <div>, I was disappointed to find that the animation wasn't working as expected. This occurred while utilizing ngAnimate alongside AngularJS version 1.2.4.

Below is a snippet of the code I implemented:

<div class="col-use-list sidebar">
    <div class="col-md-12 sidebar-element" 
         ng-animate="'animate'" 
         ng-repeat="song in songs | orderBy:[filter]:reverse" 
         style="margin-bottom: 10px;"> 

        <div class="col-use-artwork" 
             style="padding-left: 0px;">
            <img alt="{{ song.name }}" 
                 src="img/artwork/{{ song.image }}.png" 
                 class="sidebar-song-image">            
        </div>

        <div class="col-use-name">      
            <p>{{ song.name }}</p>            
        </div>

        <div class="col-use-select">        
            <input type="radio" 
                   name="checkbox"  
                   ng-value="song.image" 
                   id="{{ song.image }}" 
                   class="sidebar-checkbox" />
            <label for="{{ song.image }}" class="sidebar-checkbox-label"></label>            
        </div>            
    </div>

    <div style='clear:both;height: 0;'></div>
</div>

app.js

var SongApp = angular
    .module('SongApp', 
        [
          "ui.router", 
          "ngUpload", 
          "pascalprecht.translate", 
          "ngAnimate"
        ]);

css

.animate-enter, 
.animate-leave { 
    -webkit-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -moz-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -ms-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -o-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    position: relative;
    display: block;
} 

.animate-leave.animate-leave-active,
.animate-enter {
    -webkit-transform: scaleY(0);
    -moz-transform: scaleY(0);
    -ms-transform: scaleY(0);
    -o-transform: scaleY(0);
    transform: scaleY(0);
    height: 0px;
    opacity: 0;
}

.animate-enter.animate-enter-active,
.animate-leave {
    -webkit-transform: scaleY(1);
    -moz-transform: scaleY(1);
    -ms-transform: scaleY(1);
    -o-transform: scaleY(1);
    transform: scaleY(1);
    height: 30px;
    opacity: 1;
}

Answer №1

When referring to the documentation for angular v1.2.4, it is noted that the utilization of the ng-animate service has undergone a change. Now, the specification of classes with animations should be done in the traditional way.

Give this a try:

html:

<div class="col-use-list sidebar">
    <div class="col-md-12 sidebar-element animate" 
         ng-repeat="song in songs | orderBy:[filter]:reverse" 
         style="margin-bottom: 10px;"> 

        <div class="col-use-artwork" 
             style="padding-left: 0px;">
            <img alt="{{ song.name }}" 
                 src="img/artwork/{{ song.image }}.png" 
                 class="sidebar-song-image">            
        </div>

        <div class="col-use-name">      
            <p>{{ song.name }}</p>            
        </div>

        <div class="col-use-select">        
            <input type="radio" 
                   name="checkbox"  
                   ng-value="song.image" 
                   id="{{ song.image }}" 
                   class="sidebar-checkbox" />
            <label for="{{ song.image }}" class="sidebar-checkbox-label"></label>            
        </div>            
    </div>

    <div style='clear:both;height: 0;'></div>
</div>

css:

.animate.ng-enter, 
.animate.ng-leave { 
    -webkit-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -moz-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -ms-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -o-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    position: relative;
    display: block;
} 

.animate.ng-leave, animate.ng-leave-active,
.animate.ng-enter {
    -webkit-transform: scaleY(0);
    -moz-transform: scaleY(0);
    -ms-transform: scaleY(0);
    -o-transform: scaleY(0);
    transform: scaleY(0);
    height: 0px;
    opacity: 0;
}

.animate.ng-enter, animate.ng-enter-active,
.animate.ng-leave {
    -webkit-transform: scaleY(1);
    -moz-transform: scaleY(1);
    -ms-transform: scaleY(1);
    -o-transform: scaleY(1);
    transform: scaleY(1);
    height: 30px;
    opacity: 1;
}

If you refer to the documentation from version 1.2 onwards, the usage of ngAnimate has been modified. A specific class with animation needs to be defined, along with adding ng-enter or ng-leave in your css. The Angular service will automatically incorporate ng-enter or ng-leave for your class in the DOM.

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 functionality of "Overflow-scroll true" does not seem to be operational within an iOS device when using an Ionic application

Currently, I am working on an Ionic application and focusing on improving its performance. During my research process, I have come across various suggestions primarily related to scrolling functionality. It is highly recommended to use overflow-scroll="tru ...

Ensure that the assistant stays beneath the cursor while moving it

I am currently working on creating a functionality similar to the 'Sortable Widget', but due to some constraints, I cannot use the premade widget. Instead, I am trying to replicate its features using draggable and droppable elements: $(".Element ...

Having trouble authenticating SPA using passport-azure-ad's Bear Strategy

While I was trying to integrate Azure AD into an AngularJS single page app, I encountered some difficulties getting this tutorial to work. You can find the tutorial here. The tutorial is based on the Azure AD v2.0 endpoint, but unfortunately my organizati ...

Combining multiple jQuery selector objects into one jQuery object

How can I merge two jQuery selectors into one jQuery object? I attempted to use $("#selector","#selector"), but it didn't work and just returned blank. Are there any built-in methods that can help me accomplish this? Is there a way to do it like thi ...

Invoking res.download() in the Express framework

It's puzzling why this issue is occurring, and it's quite frustrating. I was expecting the file to be downloaded in line with the guidelines provided in the Express documentation. Below is the code snippet I am using: //within React (App.js) ...

Exploring the options: choosing an element from a dropdown menu using a div tag

Struggling to choose an option from a drop-down that contains a div tag instead of the usual select tag. While my code successfully opens the corresponding div, it fails to select the desired element. Here is the snippet of HTML tags: <div id="selecta ...

Obtain a file from React Native in order to upload an image, just like using the `<input type="file" onChange={this.fileChangedHandler}>` in web development

After experimenting with different methods, I attempted to achieve the desired result by: var photo = { uri: uriFromCameraRoll, type: 'image/jpeg', name: 'photo.jpg', }; and integrating axios var body = new FormData( ...

Adding array elements to a JavaScript object

I find myself in a rather unique predicament that I'm struggling to navigate. I have come across some data structured as follows. Please bear with me if I use any incorrect terminology, as I am relatively new to this. usersByName: { "tester&q ...

Linking text to specific spot on image

I am seeking a solution to anchor a text input box to a specific spot on an image. Although I can achieve this using CSS, the problem arises when I resize my window and the alignment of the input box is lost. While I want to allow some resizing of the win ...

Displaying adornments in a vertical arrangement within a TextField using Material UI

Is there a way to display adornments vertically in a Material UI Textfield? I've been trying but it always shows up horizontally. Snippet: <TextField variant="filled" fullWidth multiline rowsMax={7} onFocus={() => h ...

Error encountered during the execution of the store method in Ajax CRUD operation

Greetings, I'm encountering an error in my AJAX code every time I try to execute the store function Below is my controller: public function store_batch(Request $request) { $rules = array( 'batch_name'=>'required:max:20| ...

Uploading multiple files using Spring Boot

My goal is to upload multiple images using ng-file-upload with Spring Boot. However, I am facing an issue where AngularJS seems to be sending the files in the wrong order, without any sequence. For example, when I select images 0 1 2 3 4 5, I expect them ...

Updating an HTML value based on the selected option using JavaScript

I'm working on a form that included a select element: <select class="form-control"> <option>10 pc</option><!--1 USD --> <option>20 pc</option><!--2 USD --> <option>50 pc</option><!--3 USD ...

Filtering in AngularJS based on a specific ID

Currently, I am dealing with a JSON encoded response from PHP that looks like this... [ {"ID":"149","IDusr":"4","aut_more_info":"good","doc_name":"img1838142879.jpeg","doc_type":"jpg"},{"ID":"149","IDusr":"4","aut_more_info":"good","img5733250433.jpeg","d ...

What are the guidelines for storing an object on $rootScope in AngularJS?

While browsing through various tutorials on authentication, I came across a common practice of placing an 'auth' object on $rootScope. This approach is notably seen in the AngularFire-seed project created by the FireBase team. I've always b ...

JavaScript: Efficiently Sorting a Multidimensional Array

Here is the array that needs to be sorted based on the third item: const array = [ [1, "Convention Hall", "Mumbai", 10, "XYZ Company"], [2, "Auditorium", "Delhi", 10, "ABC Company"], [3, "CenterHall", "Bangalore", 10, "ZZZ Company"], ... ...

Using Javascript, Google Charts is able to interpret JSON data

I am currently working on integrating Google Charts and populating it with data from an external JSON file that I have generated using PHP's json_encode() function. After some effort, I managed to get Google Charts to display data successfully, but f ...

Guide on retrieving a file through an HTTP request with restricted cross-origin access restrictions

Having some issues with downloading files from specific links, such as . My goal is to automate the download process for these redirected files. The challenge I'm facing is that trying to access the link directly through a web browser just gives me a ...

Generate a fresh array using the information extracted from a JSON file

I need assistance in extracting a new array from JSON data. The desired output should be an array containing "itog" values. [12860498,20156554,19187309] [ { "0": { "itog": 12860498, "return": ...

What is the best way to retrieve the nearest form data with jQuery after a child input has been modified?

I have a page with multiple forms, each containing several input checkboxes. When one of the form inputs changes, I want to gather all the parent form's data into a JSON array so that I can post it elsewhere. I'm having trouble putting the post ...