Creating smooth transitions using Angular's ngif directive along with CSS animations to slide elements in and out

I am currently working on a side panel that needs to slide in and out when a button is clicked, and I want to achieve this using pure CSS.

However, I'm struggling to make the transition smooth. I've experimented with keyframes but haven't been able to achieve the desired result.

You can find my code on jsFiddle.

Below is the CSS code I've been working with:

.showFlyoutPanel.ng-enter, .showFlyoutPanel.ng-leave {

}


.showFlyoutPanel.ng-enter,
.showFlyoutPanel.ng-leave.ng-leave-active {
  -webkit-animation-name: slideOut; /* Chrome, Safari, Opera */
    -webkit-animation-duration: 4s; /* Chrome, Safari, Opera */
    -webkit-animation-direction: reverse; /* Chrome, Safari, Opera */
    animation-name: slideOut;
    animation-duration: 4s;
    animation-direction: reverse;    
}

.showFlyoutPanel.ng-leave,
.showFlyoutPanel.ng-enter.ng-enter-active {
   -webkit-animation-name: slideIn; /* Chrome, Safari, Opera */
    -webkit-animation-duration: 4s; /* Chrome, Safari, Opera */
    -webkit-animation-direction: forwards; /* Chrome, Safari, Opera */
    animation-name: slideIn;
    animation-duration: 4s;
    animation-direction: forwards; 
}



/* Chrome, Safari, Opera */
@-webkit-keyframes slideIn {
    0%   {right:-100px;}
  25%  {right:-75px;}
  50%  {right:-50px;}
  75%  {right:-25px;}
    100% {right:0;opacity: 1;}
}

/* Standard syntax */
@keyframes slideIn {
     0%   {right:-100px;}
  25%  {right:-75px;}
  50%  {right:-50px;}
  75%  {right:-25px;}
    100% {right:0;opacity: 1;}
}


/* Chrome, Safari, Opera */
@-webkit-keyframes slideOut {
    0%   {right:0px;}
    25%  {right:25%;}
    50%  {right:50%;}
    75%  {right:75%;}
    100% {right:100%;}
}

/* Standard syntax */
@keyframes slideOut {
    0%   {right:0px;}
    25%  {right:25%;}
    50%  {right:50%;}
    75%  {right:75%;}
    100% {right:100%;}
}

Answer №1

After reviewing these code snippets, I was able to arrive at the solution. However, I am seeking confirmation on the accuracy of the provided code set. Additionally, could you please explain the purpose of the following:

.showFlyoutPanel.ng-enter, .showFlyoutPanel.ng-leave { }

.showFlyoutPanel.ng-enter, .showFlyoutPanel.ng-leave {

}

.showFlyoutPanel.ng-enter,
.showFlyoutPanel.ng-leave.ng-leave-active {
  -webkit-animation-timing-function: ease-in-out;  
  -webkit-animation: slideOut 5s; /* Chrome, Safari, Opera */
    animation: slideOut 5s ;
}

.showFlyoutPanel.ng-leave,
.showFlyoutPanel.ng-enter.ng-enter-active {
    -webkit-animation: slideIn 5s; /* Chrome, Safari, Opera */
    animation: slideIn 5s ;
  -webkit-animation-timing-function: ease-in-out;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes slideIn {
    from {left: 100%;}
    to {left: 0px;}
}

/* Standard syntax */
@keyframes slideIn {
    from {left: 100%;}
    to {left: 0px;}
}

/* Chrome, Safari, Opera */
@-webkit-keyframes slideOut {
    from {left: 0px;}
    to {left: 100%;}
}

/* Standard syntax */
@keyframes slideOut {
   from {left: 0px;}
    to {left: 100%;}
}

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

Go back to the previous state prior to installing a bower component

I recently added angular-pdf to my project using Bower, and encountered an interesting prompt during the installation process. Unable to find a suitable version for angular, please choose one: 1) angular#>=1 <1.3.0 which resolved to 1.2.28 and i ...

What is the correct way to include '?i#efix' in a font directory path in a Rails application?

It is suggested to include ?#iefix at the end of .eot font paths in order to resolve another erratic behaviour issue in IE: @font-face { font-family: 'MyWebFont'; src: url('webfont.eot'); /* IE9 Compat Modes */ src: url(&ap ...

Angular causing alignment issues for items not centered

I'm having trouble centering the contents of a div with my code. The properties I am applying don't seem to work. Any idea why this is happening? <div class='center'> <form (ngSubmit)="loginUser()" style="background: steel ...

The outline feature cannot be applied to buttons within a btn-group in Bootstrap 4

I have successfully removed the outline for a single button, but I am struggling to remove it for a button within a btn-group class. Check out my JSFiddle DEMO This is the HTML code I am working with: <button class="btn btn-primary">Button without ...

Include the attribute exclusively for the initial division within a group of corresponding elements

Looking to change the appearance of this HTML code without being able to edit it directly? <form method="POST" id="go123pago"> <div align="center" style="width:220px"> <div style="float:left;padding:10px;width:190px"> ...

Issue: Trouble with Rotating Tooltips in Javascript

I am facing a challenge with the tooltips on my website. I want to ensure that all tooltips have a consistent look and transition effects, but I am struggling to achieve this. The rotation and other effects applied using javascript are not functioning prop ...

Click event not triggering to update image

I'm currently working on a Codepen project where I want to use JavaScript to change the image of an element with the id "chrome". However, my code doesn't seem to be working as expected. Can someone help me troubleshoot and fix this issue? Your a ...

Adjust the spacing between the title and other elements in an R Shiny application

How do I modify the font and size of a title, as well as add some spacing between the title and other elements? navbar <- navbarPage( Title = "Intervals", tabPanel("Data Import", sidebarLayout(sidebarPanel(fi ...

AngularJS collapsible data row is a powerful feature that allows users to easily

I am looking to present parent and child related data in an expandable format without relying on panels. Example: <div ng-app="app" ng-controller="customersCtrl"> <table st-table="rowCollection" class="table table-striped"> &l ...

Stopping horizontal scrolling in Material-UI Autocomplete/Popper: A troubleshooting guide

I am currently working on incorporating the Material-UI Autocomplete component, and my goal is to have each option label show an icon along with some text. The challenge I'm facing is that I only want the popper element to be the width of the text inp ...

Eliminate any empty spaces and gaps present between div elements

Is there a way to eliminate the spaces between div containers at the bottom part of the div with a red border? The following code snippets utilize materializecss. /*############################ LOGIN STYLE ############################*/ body{ font: ...

Utilizing a shared directive across multiple pages while maintaining its state

In my AngularJS app with multiple pages configured using $routeProvider, I have created a reusable directive that contains buttons allowing for callbacks and inputs. However, the directive relies on a service to maintain its state when transitioning betwee ...

Transmit information from the main directive to the subordinate directive

Hi everyone, I have a quick question.. I'm working on a directive that includes an ng-repeat and transclude, with several child directives inside it that need to inherit specific objects from each iteration... So far, I've only managed to achiev ...

Set the height of the vertical scroll at a fixed 100% floatValue

Check out my creation at http://jsfiddle.net/ZygnV/ html, body { margin: 0; padding: 0; height: 100%; } .main-content-wrapper { height: 100%; overflow-y: hidden; white-space: nowrap; } .main-sidebar { display: inline-block; height: 1 ...

There is no class present in the @Apply layer with Tailwind styling

I've been searching for what seems like a simple solution, but I can't seem to find it. While researching similar issues, I noticed that people were having problems with the Hover style and extra white space after it, which is not the issue in my ...

Display a confirmation modal before triggering $routeChangeStart in AngularJs, similar to the window.onbeforeunload event

When a user chooses to stay on the page as the route starts to change, the original route remains intact but the form directives are reloaded. This results in the loss of all checkbox and input values, resetting them to their defaults. If a user closes th ...

Only apply prevent default on specific levels for better control

I am currently working on a menu with submenus. I am facing an issue where when I click on a top-level menu item, I need to use prevent default because they are anchor tags. However, for the submenu items, I do not want to prevent default behavior. I am st ...

Tips for navigating through a div with an unknown height

I am currently working on developing a sleek messaging system and I have encountered an issue with the interface design. My project is built using Materialize, however, I am open to tweaking it with custom CSS if necessary. The layout consists of a list of ...

The functionality of the Bootstrap carousel for moving to the next and previous images is malfunctioning, as it only

The carousel on my website is not functioning properly. It only displays the first image and does not slide to the next pictures as it should. Here is the code snippet for the carousel: <body> </nav> <div id="carousel1" class="carousel slid ...

Is there a compatibility issue between ui.bootstrap tooltip and ng-model in an input element?

My goal is to incorporate an input element with a tooltip and connect a function to the enter keypress event. Individually, each of these features works, but when combined, they seem to be causing an issue. The following is the code snippet: <input t ...