Experience a dynamic sliding effect when hiding elements with AngularJS using the ng-hide directive and ng

If you take a look at my jsfiddle http://jsfiddle.net/99vtukjk/, you'll see that currently, when clicking on the left or right text, the hide animation moves upwards. Is there a way to change this animation to slide and fade to the left menubar instead?

   <body ng-app="myApp1">
       <div id='outerdiv' ng-controller="MyCtrl" >
             <div ng-click="myValue=true" >LEFT</div>
             <div  ng-click="myValue=false">RIGHT</div>
               <div id="one" class='animate-hide'  ng-hide="myValue"> 
               this is just a sample div
               </div>
         {{myValue}}
       </div>
   </body>

CSS:

.animate-hide {
 -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
    -moz-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
    -o-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
    transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 2s;
  line-height:20px;
  opacity:1;
  padding:10px;
  border:1px solid black;
  background:white;
}

.animate-hide.ng-hide {
  line-height:0;
  opacity:0;
  padding:0 10px;
}

Angular Module

  var app = angular.module("myApp1", ["ngAnimate"]);
    app.controller("MyCtrl", function ($scope) {
    $scope.myValue=false;
    });

Answer №1

If you want to hide an element, you can apply the CSS property left: 0 to the class .animate-hide.

To animate the hiding process, use left: -100% for the class .animate-hide.ng-hide.

Check out this live example on JSFiddle

Enhance your animations with Animate.css

Animate.css offers a wide range of creative and cross-browser animations for your projects.

Answer №2

Be sure to take a look at the ngAnimate library. It's truly incredible.

For a demonstration, visit this DEMO

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

Confusion in NodeJs and Express response handling

I am having an issue with my tabular form page where I have a controller assigned to each row, and based on the column value, I'm setting variables within the controllers. However, when I make multiple simultaneous requests to the same controller but ...

"Enhance Your CSS Styling with an Additional Dot for Dotted Under

Is it possible to make the dots at the end and sometimes beginning of a word thicker and more round? https://i.stack.imgur.com/W9WPi.png ' CODE <span style="border-bottom: 3px dotted #111;">Personal Project Magazine Ads Personal Project Magaz ...

Discovering the current state's name with AngularJS

I am trying to access the current state name in my run() function using $state.current.name, but it seems to be returning an empty string. $rootScope.$on('$stateChangeStart', function (event, next) { var json = (function ...

Creating a three-column layout in CSS with only two divs

Struggling to format a page with 3 columns using only 2 divs for the contents. One div affects just the end of the content, while the other impacts all of it. Currently, the layout is like this: This is the first content-------------------This is the se ...

Display a list in thumbnail format on Wordpress

On my website, , the homepage thumbnail post does not display the text in a bulleted list like it does when I enter the post directly at . Can you explain why this is happening? I want to note that the theme admin supports Custom CSS which allows me to ad ...

Executing Promises in a loop: TypeScript & Angular with IndexedDB

Currently, I am working on a data synchronization service where data is being retrieved from a web service and then stored in IndexedDB. In my TypeScript Angular Service, the code looks something like this: this.http .post(postUrl, postData) .suc ...

How can I duplicate an element twice in AngularJS, without having them appear right after each other?

Within my AngularJS template html file, I am faced with a dilemma regarding an html element: <div>This is a complex element that I want to avoid typing multiple times</div> My challenge is that I need this element to show up twice on my websi ...

AngularJS issue: Unable to reset scope variable

I am facing an issue with a function in my angularJS controller that is triggered on a dropdown option change: Currently, when a default option is selected, the corresponding records from the database are fetched and set to a scope variable. Everything s ...

the ng-click event handler is not triggering the function

<body ng-app="groupChatApp" ng-controller="groupChatController"> <div id="error-container">{{errorValue}}</div> <div ng-model="changeForm" id="changeForm"> <input id="name" type="text" name="name" value="" placeho ...

Customized Quick Access MUI

Hey there! I'm currently working with the Speed ​​dial component for MUI and I'm having trouble figuring out how to style the tooltipTytle. I can only seem to style them when they are all displayed at once, but that's not what I want. I ...

Tips for centering text in a dijitTextBox:

Ensure that the text is centered vertically with left padding and placeholder text included Check out the image link below: https://i.stack.imgur.com/PbHDa.jpg Snippet of my xPage code: <xe:djTextBox id="djTextBoxSearch" style="width:100%;height: ...

Tips for creating shaped images using clip-path

Can an image be clipped to match a specific shape using the clip-path CSS property? Original Image https://i.stack.imgur.com/rYeuk.jpg Desired Result with CSS https://i.stack.imgur.com/6FYfn.png ...

What are the best practices for creating a contemporary website that functions effectively on IE7?

After creating several websites for my clients, I discovered that they are not functioning well in IE7. Unfortunately, there is still a small percentage of people using IE7. Can anyone suggest a super quick solution to fix this issue? Feel free to recomm ...

Automate CSS slideshow playback using JavaScript

Using only CSS, I created a basic slideshow where the margin of the element changes upon radio button click to display the desired slide. You can view the functionality in the code snippet below. Additionally, I implemented auto play for this slideshow usi ...

Is there a way to simultaneously send an HTML file and variables in nodejs?

Looking for a way to send HTML and variables without using locals or res.render, as each client may have different pages. The pages are stored in MongoDB along with the HTML and variables that need to be sent together. Any suggestions on how to accomplish ...

Nav Bar Toggle Button - Refuses to display the dropdown menus

My Django homepage features a Bootstrap navbar that, when resized, displays a toggle button. However, I am experiencing difficulty with dropdown functionality for the navbar items once the toggle button is activated. Can anyone provide guidance on how to a ...

Creating a visually stunning image grid akin to the meticulously designed layouts found

Forgive my lack of knowledge, but I'm curious about how to create an image or text grid similar to Tumblr using HTML and CSS. I'm looking to achieve a layout like this: ...

Click on the submenu to expand it, then simply select the desired option to navigate

I have created a toggle menu that displays a list of child elements when clicked, and hides them if clicked again. However, when a child element is clicked, I want it to navigate to the corresponding page. I am having trouble getting this functionality to ...

How to modify the link to ensure that a particular tab is already selected when the page loads

How to Add Script for Linking to Rawdata Tab I need help loading specific page content with the Rawdata tab open instead of the Summary tab. What code should I add to the link to ensure that the page loads with "Rawdata"? https://i.stack.imgur.com/avETs. ...

Utilize the synchronization feature of ES6 Promises in Jasmine with the then/catch method

I have an angular controller that needs to be tested. This controller utilizes a service to fetch data from a server, and the service returns ES6 Promises. function MyController($scope, MyService) { $scope.doSomething = function () { MyService.foo() ...