The animation feature in Angular JS seems to be malfunctioning

Currently in the process of creating a slideshow using AngularJS, similar to the one found at this link, which includes navigation arrows (next and prev).

Here is the HTML code snippet:

<div class="carousel">
   <div class="left"><input type="button" value="Back" ng-click="slideBack()" ng-disabled="currentSlide == 0" /></div>
   <div class="content">
         <div class = "slide" ng-repeat="img in imgs | startFrom:currentSlide | limitTo:slidesSize" ng-animate="{enter: 'animate-enter', leave: 'animate-leave', move: 'animate-move'}">
    <img ng-src="{{img.url}}" />
         </div>
   </div>
   <div class="right"><input type="button" value="Next" ng-click="slideNext()" ng-disabled="currentSlide+slidesSize >= imgs.length" /></div>
        </div>

The relevant CSS code can be seen below:

.animate-enter, .animate-move, .animate-leave
{ 
    -webkit-transition: 1000ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -moz-transition: 300ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -ms-transition: 300ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    -o-transition: 300ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
    transition: 300ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
} 

.animate-enter {
      left: 400px;
      position:relative;
      opacity: 0;
}
.animate-enter.animate-enter-active {
      left: 0px;
      opacity: 1;
}

.animate-move {
      position:relative;
}
.animate-move.animate-move-active{
      left: -200px;
}

.animate-leave {
      left: 0;
}
.animate-leave.animate-leave-active{
      left: -100%;
      position:absolute;
}

Filter implementation for the slideshow:

angular.module('carouselFilters', []).filter('startFrom', function() {
    return function(input, start) {
        start = +start;
        return input.slice(start);
    }
});

Controller handling the slideshow functionality:

function carouselCtrl($scope, $http) {
  $scope.currentSlide = 0;
  $scope.slidesSize = 3;

  $http.get('carousel_images.json').success(function(data) {
        $scope.imgs = data;
  });

  $scope.slideNext = function(){
        $scope.currentSlide++;
  }

  $scope.slideBack = function(){
        $scope.currentSlide--;
  }


}

The animate-enter and animate-leave transitions are functioning properly, however, experiencing issues with the animate-move transition. Any suggestions or ideas would be greatly appreciated.

Thank you.

Answer №1

  • use "enter" when a DOM element joins the repeat list.
  • employ "leave" when a DOM element exits the repeat list.
  • utilize "move" when a DOM element transitions from one position to another within the repeat list.

I was inspired by an example I found on nganimate.org.

In my scenario, there is a collection of items displayed using ng-repeat.

line 21: <li ng-animate="'animate'" ng-repeat="name in names | filter:search">

In my stylesheet style.css, I followed the same CSS approach as you did.

To showcase the animation effect, I added a button that shuffles the li's around using _.shuffle.

<button ng-click="shuffle()">Shuffle the List</button>

It seems more like adding/removing elements from the repeat list rather than moving them physically. I hope this clarifies things.

Apologies for saving the incorrect version - http://plnkr.co/edit/ZXkwx7Skuy42ndWexMt0

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

Develop a new variable protocol that adheres to a different protocol

In my Swift project, I am working on creating an animator that will be used across all my view controllers by creating a specific object for each one. This animator object must conform to the Animator protocol. Check out the example below: Here is the Ani ...

Height not being generated by Div element

I am encountering an issue with a div element that contains an h2 and three nested div elements. Despite not explicitly setting a height for the container div, it is not expanding to accommodate the varying heights of the inner divs. This problem is causin ...

I'm interested in exploring whether p5.js allows for the creation of a class that can draw sub-classes within itself. One idea I have in mind is to create a 4x4 grid composed of individual

My goal is to create a game similar to Tetris, where the pieces are composed of smaller blocks that share attributes. My current progress includes: export class SquareTetromino { [x: string]: any; constructor(x, y, w, h) { ... } ...

Achieving Vertical Alignment in a Bootstrap 4 Image Overlay Card

I am facing a challenge in trying to vertically center a FontAwesome icon within an Image Overlay Card. Despite attempting various methods like using d-flex and justify-content-center, none of them seem to be effective. What could I be overlooking? < ...

Retrieve JavaScript functions as JSON or text in AngularJS and execute them

Currently, I am working on developing an AngularJS application and have come across a particular challenge that needs to be addressed: After making a web service call, I receive JavaScript code that looks like this: { "script":"function foo(a, b) { c = ...

Display a scrollbar for the offspring of an element with a flex-grow value of 1

I'm seeking to create a straightforward design consisting of a layered header, main section, footer. My framework of choice is bootstrap 5. The complete layout should occupy all available width and height, with overflow (x and y) set to hidden. Hea ...

Retrieve the result set rows and store them in an array as individual objects

I'm attempting to fetch data from a MySQL database using Angular and PHP. My Angular code looks like this: $http({ url: "http://domain.com/script.php", method: "POST", headers: {'Content-Type': 'applica ...

While my other function remains incomplete, AngularJS $http continues to run without interruption

I'm facing an issue in my AngularJS function where the $http request is being fired before my first function is completed. Here's a sample of how my code looks: $scope.function = function(){ $scope.functionOne(); // This function initializ ...

Place an image in the middle of a div

Here are a few images for you to consider: <div class="builder-item-content row"> <div class="twelve columns b0" style="text-align:center;"> <ul class="upcoming-events"> <li> <a href="http://www.padi.com/scub ...

Manage several scrolls using overflow:auto

There are numerous popups on a page with the overflow:auto property. The structure is as follows - <div id="popup1"> <div>SomeHTMLSTRUC</div> <div>SomeHTMLSTRUC</div> <ul class="scroll"></ul> </div> ...

Implementing scroll-based animations in VUE.JS with a similar effect to wow.js

Is there a way to incorporate animation into certain blocks while scrolling on my Vuejs website similar to wow.js? If you have any suggestions, I would greatly appreciate it. Thank you! ...

Exploring AngularJS tab navigation and injecting modules into the system

Two separate modules are defined in first.js and second.js respectively: first.js var app = angular.module('first',['ngGrid']); app.controller('firstTest',function($scope)) { ... }); second.js var app = angular.mo ...

Searchbox aligned to the right using Bootstrap

Looking to place a searchbox on the right next to another container aligned left: <div> <div class="pull-left"><span>SOME TEXT</span></div> <div class="pull-right"> <div class="row"> ...

How can I expand all nodes using breezejs?

Is it possible to expand all child nodes within an entity using the breezejs query statement, perhaps even up to 2 levels deep? The situation is that I am creating a partial entity for the list page, but when editing a single entity, I want to display all ...

What is the best approach for writing an asynchronous function while utilizing $rootScope.broadcast within a continuous loop?

At least 10 times a second, I have a function that is called. Each time, there are approximately 100 records with variations in LastSeenTime and ReadCount. In this simulation scenario, I understand the behavior; however, in real-time, the number of records ...

Is it possible to utilize the Linear-gradient property for creating a vertical background color effect?

I'm currently attempting the following: body { height:100%; background: -moz-linear-gradient(left, #DB2B39 50%, #2B303A 50%); background: -webkit-linear-gradient(left, #DB2B39 50%,#2B303A 50%); background: linear-gradient(to right, #D ...

The issue of flickering during the combination of slideToggle and animate in jQuery

I want to incorporate a hidden div that, when triggered by a button click, will smoothly reveal itself and "push" away part of another div without changing the overall size of the containing div. However, I have encountered an issue where the div below th ...

Css flex is not compatible with Safari, iPhone 5, and some mobile web browsers' webviews

All of the following code snippets are written in HTML: <div class="btn-toolbar text-center" role="toolbar"> <a href="#" class="btn btn-success">Link 1</a> <a href="#" class="btn btn-success">Link 11</a> < ...

Creating a search form in Bootstrap 4 that is centered and expands to full width only on small screens

I'm currently working with a bootstrap v.4 navbar that has 3 elements in it. I've managed to align the elements evenly so that the search bar is centered in the navbar. However, when it collapses it takes up the full width of the screen. Here is ...

Leveraging Iframes for efficient user authentication within an Angular application

Incorporating an Iframe into one of my templates for authentication has presented certain challenges. Case in point: When a user finishes a training session, they must verify their identity by authenticating with a ping identity server that will redirect ...