AngularJS ngAnimate triggering prematurely

In the current setup, p2 animates in while p1 is still animating out. After that, p1 disappears and p2 glitches up the page. The desired effect is for 1 to fade out and then have 2 fade in.

html:

 <nav>
    <a ng-click="changeView('p1')">p1</a>
    <a ng-click="changeView('p2')">p2</a>
 </nav>
 <div ng-view class="page">
 </div>

css:

.page {
    border:1px solid red;
    background-color:#eee;
    transition:all 1s linear;
}

.page.ng-enter {
    -webkit-opacity:0;
    opacity:0;
}

.page.ng-enter-active {
    -webkit-opacity:1;
    opacity:1;
}

.page.ng-leave {
    -webkit-opacity:0;
    opacity:0;
}

.page.ng-leave-active {
    -webkit-opacity:1;
    opacity:1;
}

Is there a conventional method to achieve this? I've attempted using ng-enter-stagger as suggested by yearofmoo but haven't had any success.

Answer №1

Instead of using a traditional transition, consider implementing an animation with a delay that activates at 50%. In SASS, you can achieve this effect by:

// Define keyframes for the animation
+keyframes( myOut )
  0%
    +opacity( 1 )
  50%, 100%
    +opacity( 0 )


+keyframes( myIn )
  0%, 50%
    +opacity( 0 )
  100%
    +opacity( 1 )

// Apply animations to respective classes
.page.ng-enter-active
    +animation( myIn 1s 1 )

.page.ng-leave-active
    +animation( myOut 1s 1 )

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 type 'myInterface' cannot be assigned to the type 'NgIterable<any> | null | undefined' in Angular

I am facing an issue that is causing confusion for me. I have a JSON data and I created an interface for it, but when I try to iterate through it, I encounter an error in my HTML. The structure of the JSON file seems quite complex to me. Thank you for yo ...

Using a for loop, how can the property value be set in another object?

One challenge that I am facing is setting object property values. The object in question looks like this: const newPlan = { name: '', description: '', number: '', monday: { breakfast: '', ...

Displaying various results using a range slider

I really need some assistance in making this range slider produce multiple outputs. I've attempted a few different options, but unfortunately, I haven't been able to figure it out. My goal is to have the text "590" display as 5.9 times the value ...

Understanding text overflow in JavaScript and jQuery

I am facing an issue where the text in some columns of my table is breaking into two lines. I believe reducing the font size will resolve this problem, but I am unsure about where to start coding for this particular issue. If you have any ideas or sugges ...

Could anyone clarify the concept of how a function is able to be equivalent to zero?

function checkForSpecialCharacters(text) { var specialChars = [";", "!", ".", "?", ",", "-"]; for(var i = 0; i < specialChars.length; i++) { if(text.indexOf(specialChars[i]) !== -1) { return true; } } ...

The issue of Rails 4 serving JavaScript as plain text instead of executing it when attempting to utilize AJAX

I am in the process of constructing a basic page layout featuring two side-by-side columns. The left column is intended for user input via a form submission. Upon submitting the form, I want the right column to dynamically update (using AJAX) and display a ...

Arranging pre-selected checkboxes in MUI Datatable

I noticed that the checked data is appearing at the top of MUI data tables without any sorting. Checkbox In this image you can see that all the checked boxes are mixed up without any order. I would like to have all the checked rows displayed together and ...

Switch back and forth between multiple functions

It appears that the code provided is not functioning correctly with jQuery versions higher than 1.8. Can anyone offer insight on how to achieve the same functionality with newer versions? Additionally, should we be structuring our code like element.click(f ...

Jest's JavaScript mocking capability allows for effortless mocking of dependent functions

I have developed two JavaScript modules. One module contains a function that generates a random number, while the other module includes a function that selects an element from an array based on this random number. Here is a simplified example: randomNumbe ...

The error message "Attempting to send a message using an undefined 'send' property in the welcomeChannel" is displayed

bot.on('guildMemberAdd', (member) => { console.log(member) const welcomeChannel = member.guild.channels.cache.find(channel => channel.name === 'welcome'); //const channelId = '789052445485563935' // welcome c ...

Error in Internet Explorer 8 - the object does not support this property or method

My ExtJS custom "treecombo" works perfectly in Firefox and Chrome, but encounters issues in Internet Explorer. Specifically, I am facing problems with IE8 when trying to run the following code: Ext.define('MyApp.plugins.TreeCombo', { extend: & ...

How to manage UNC paths and "mapped network drives" within an Electron application?

I have developed a cross-platform (macOS-Windows) app using Electron that functions smoothly with files and media assets from a local drive. However, it encounters issues when dealing with UNC paths and "mapped network drives". Since I am a contractor, I d ...

Best practices for referencing attributes created with the data method in a Vue component

In my application, there is a section that displays a list of users along with a search box to filter names. The user information is fetched from a database and stored in app.users. I have created a component named 'user' to show the details of e ...

Outdated JavaScript Alert

Is it possible to use JavaScript to create an alert message in my input field when a past date is selected? I would like the warning to say "past date, please enter a valid date." <html lang="en"> <head> <meta charset="U ...

Issues with table formatting and malfunctioning functions

I created a basic tic-tac-toe game, but I'm having an issue with the table display. It appears squished when the game loads. Is there a way to prevent this and keep the table empty? Additionally, I am using NotePad++ and encountering problems running ...

"Implementing conditional evaluation for pixel units in AngularJS using ng-style

Looking to adjust the style of an element based on its height. For example, if the height is less than X, apply 'style 1'; otherwise, apply 'style 2'. The syntax appears to be correct, but accurately evaluating the height property in p ...

Error: The jQuery Class is returning an undefined value

I have been working on creating a basic AJAX request class in jQuery. However, I've encountered an issue with the 'process' function where I can get the response from the variable 'response'. When I return 'response', it ...

The backbone module is experiencing formatting issues

I'm new to learning backbone.js. I've created the example below, but unfortunately, it's not functioning properly. Can someone please help me understand why? The goal is to simply display the name within my div element. (function($) { ...

React - Clearing State data retrieved from axios request

I am currently facing an issue with resetting the state of an object in my users array upon clicking the delete button. Even after successfully removing the object from the database, the state does not update as intended. I have managed to verify the prese ...

developing a stand-alone job listings feature

Our website features a job postings page that our clients are interested in incorporating into their own websites. This would allow applicants to easily apply for jobs directly on the client's site, with the information being saved in our system. One ...