I am currently facing a challenge in animating my ng-show/ng-hide animation

This particular issue has been widely recognized and discussed multiple times in various forums. Despite the extensive search, I have not come across satisfactory solutions.

var aniApp = angular.module("aniApp", []);

aniApp.controller('mainCtrl', ['$scope',
  function($scope) {
    $scope.currentStep = 1;

    $scope.show = function(step) {
      $scope.currentStep = step;
    }
  }
]);
.step-box {
  width: 200px;
  border: solid 1px silver;
  padding: 20px;
}
.animate-show {
  width: 200px;
  border: solid 1px silver;
  padding: 20px;
}
.animate-show.ng-hide-remove,
.animate-show.ng-hide-add {
  display: block!important;
}
.animate-show.ng-hide-add {
  animation: 1s flyOut;
}
.animate-show.ng-hide-remove {
  animation: 1s flyIn;
}
@keyframes flyIn {
  from {
    left: 600px;
  }
  to {
    left: 0;
  }
}
@keyframes flyOut {
  from {
    left: 0;
  }
  to {
    left: -600px;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="aniApp">
  <div ng-controller="mainCtrl">
    <div ng-show="currentStep === 1" class="step-box animate-show">
      displaying step 1
    </div>
    <div ng-show="currentStep === 2" class="step-box animate-show">
      displaying step 2
    </div>
    <div ng-show="currentStep === 3" class="step-box animate-show">
      displaying step 3
    </div>
    <br/>
    <a href="#" ng-click="show(1)">One</a>&nbsp;
    <a href="#" ng-click="show(2)">Two</a>&nbsp;
    <a href="#" ng-click="show(3)">Three</a>
  </div>
</div>

Click the link below to access my plunker:

http://plnkr.co/edit/q11n9F?p=preview

I am trying to achieve an effect where the text enters from the right side of the box and exits on the left. Surprisingly, accomplishing this seemingly simple animation has taken up most of my day :(

If anyone can identify why it is not functioning as expected, I would greatly appreciate your assistance.

Answer №1

Make sure to include the angular ng-animate module by adding the script tag, as it is not initially included in the core of Angular. Additionally, don't forget to inject the ng-animate module as a dependency for your app.

Add this line to your HTML:

//Insert this after the angular.min script tag
<script src="https://code.angularjs.org/1.2.23/angular-animate.min.js"></script>

And add this code to your JavaScript file:

  var myApp = angular.module("myApp", ['ngAnimate']);

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

Error: Cannot access 'muiName' property as it is undefined

i am trying to display the elements of an array within a custom card component in a grid layout. However, when the page loads it freezes and the console shows "Uncaught TypeError: Cannot read property 'muiName' of undefined" custom car ...

Adding a prefix to the imported CSS file

My React app, created with create-react-app, is designed to be integrated as a "widget" within other websites rather than functioning as a standalone application. To achieve this, I provide website owners with minified JS and CSS files that they can inser ...

Setting up a secure Node.JS HTTPS server on Cloud9 IDE

Wondering if it's possible to set up a Node.js https server in the cloud9 IDE? Check out this example of a basic https server setup in Node.js. var https = require('https'); var fs = require('fs'); var app = require('./app& ...

The JQxTreeGrid is displaying properly, however, it is not loading the data from the JSON source

Looking for some assistance with loading Json data into a Jquery grid using jqxTreegrid. Currently, the grid is displaying but not the data. Despite no errors in the debugger, I'm unable to figure out the issue. Any help resolving this matter would be ...

Tips on how to highlight a clicked list item:

I'm currently attempting to access the key={1} Element within my li. My goal is to set the activeItem in State in order to compare it with the clicked item later on. If they are equivalent, I want to apply an active class to that specific element. How ...

Sending a message through Discord.JS to a designated channel

Recently diving into Discord.JS, I am struggling to understand how to make my bot send a message to the General Chat when a new user joins. Many examples I've come across suggest using the following code: const channel = client.channels.cache.find(ch ...

Is there a workaround for the issue with AngularJs ng-disabled not functioning in Internet Explorer 9?

Having an issue with the ng-disabled directive in AngularJS. It works well in Chrome, but not in IE 9. Any suggestions on how to make it work in IE 9 would be greatly appreciated. main.html <select kendo-drop-down-list k-data-text-field="'text&a ...

Struggling to make an AJAX form function properly

I'm running into an issue while setting up a basic AJAX form. My goal is to have a message display on the same page upon successful login using a PHP form through AJAX, but currently, I get redirected to the PHP file after form submission. Can anyone ...

A step-by-step guide on showcasing the content from a textfield onto a dynamic column chart

How can I show the value from a text field in a column chart? I found the code for the chart on this website(). I tried using the code below, but nothing happens. Can someone please assist me? <script> window.onload = function () { ...

Is there a way to use Node.js to automatically redirect any random string paths back to the main home page?

Is there a way to configure my basic Node.js server to use simple paths instead of query strings for user session IDs? For instance, can I make domain.com/GH34DG2 function the same as domain.com within my web app? This format seems more visually appealing ...

Accessing new information seamlessly without the need for page refresh

For optimal mobile viewing of my website, I am considering implementing a select element. Here are the available options: HTML: <select name="select-choice-8" id="select-choice-nc"> <optgroup label="News"> & ...

Dreamweaver restricts my ability to utilize JavaScript for coding

My JavaScript isn't working in Dreamweaver. I have linked the script file correctly using the given code: <script src="file:///C:/Users/Matthew/Desktop/Untitled-2.js" type="text/script"></script> However, when I try to call it with scrip ...

Issue in CakePHP after modifying the directory of Index

I'm currently working on a project using CakePHP and have come across an issue. Our team developed an Ajax function that sends data to a PHP function responsible for adding a folder (known as "ordner" in German) to the database. Initially, everything ...

Accessing form data from Ajax/Jquery in php using $_POST variables

Thank you in advance for any assistance on this matter. I'm currently attempting to utilize Ajax to call a script and simultaneously post form data. While everything seems to be working correctly, the $POST data appears to come back blank when trying ...

Change the value of input on onClick event in React

Although this may seem simple, it is a little confusing to me. I'm having trouble understanding why the input value in the following case is not being reset. handleReset() { this.setState({ data: "" }); } <button onClick={this.handleReset}>R ...

AngularJS - Introducing blurred delay

Here is the code snippet I am working with: <div class="staff"> <input ng-model="user" ng-focus="isFocused = true;" ng-blur="isFocused = false;/> <div class="matches" ng-if="isFocused"> <div ...

Steps for retrieving multiple documents from Firestore within a cloud function

In my cloud function, I have set up a trigger that activates on document write. This function is designed to check multiple documents based on the trigger and execute if/else statements accordingly. I have developed a method that retrieves all documents u ...

Exploring the seamless integration of Material UI slider with chart js

Looking for guidance on syncing Material UI slider with chart js? I'm working on a line chart and hoping to have the x-axis value highlighted with tooltip as I slide the Material UI slider. ...

Determining the height of a Bootstrap column in relation to another element

Utilizing the grid layout from bootstrap, I have the following structure: <div id="prof_cont_enclose"> <div class="row"> <div class="prof_cont_row"> <div class="col-xs-12 col-sm-4 col-md-2 col-lg-2 prof_elem"&g ...

Obtain the position and text string of the highlighted text

I am currently involved in a project using angular 5. The user will be able to select (highlight) text within a specific container, and I am attempting to retrieve the position of the selected text as well as the actual string itself. I want to display a s ...