Encountering problem when attempting to incorporate fade in/fade out effect animation

I have a webpage that features multiple buttons, each triggering a fade-in/fade-out animation when clicked. This animation also involves changing the contents of a specific div.

Though everything is functioning properly, there is a brief moment (about half a second) where the div disappears before the fade-in animation begins, which detracts from the overall appearance. Is there a way to ensure the div remains invisible and then visible again without any changes in height? Setting the height to 100% did not resolve this issue.

CSS

.afterClick {
  -webkit-animation: fadeinout 0.6s linear forwards !important;
  animation: fadeinout 0.6s linear forwards !important;
}

@keyframes fadeinout {
  from {
    opacity: 1;
    animation-timing-function: ease;
  }
  50% {
    opacity: 0.5;
    animation-timing-function: ease-in;
  }
  to {
    opacity: 1;
    animation-timing-function: ease-in-out;
  }
}

HTML

<a href="#" class="some-class" (click)="setAnimation()">

<div class="afterClick" *ngIf="checkVisibility == 'Y'">
some contents
</div>

TS

public checkVisibility = 'Y';

setAnimation() {
  let context = this;
  context.checkVisibility = 'N';
  setTimeout(function() {
    context.checkVisibility = 'Y';
  }, 50);
}

Answer №1

Consider enhancing the .afterClick class with an animation-fill-mode

.afterClick {
  -webkit-animation: fadeinout 0.6s linear forwards !important;
  animation: fadeinout 0.6s linear forwards !important;
  animation-fill-mode: backwards;}

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

Combining the power of Visual Studio Code with NodeJs allows for seamless detection of missing package namespaces

Recently, I've encountered a frustrating problem. It occurs when: I create a new Node project without any installed modules I use import '' and press ctrl+space between the brackets, resulting in unnecessary inferred namespaces. Alth ...

What could be causing my HTML table to stretch all the way to the bottom and right?

https://i.sstatic.net/SpG52.png The layout appears to be extending to the right and bottom, despite my attempts to fix it. I am utilizing the Bootstrap table class in my code. Here is the code snippet: HTML: <head> <link rel="stylesheet" ...

Error message: Node package 'Typescript' could not be found

I've been working on setting up a project using Node and TypeScript. Unfortunately, I can't seem to figure out what's causing my settings to not work properly. I've tried different options for tsconfig/nodemon but nothing seems to be c ...

What is the best way to dynamically adjust the size of a Google map on my website automatically

I need assistance with placing a Google map on a webpage along with textboxes in the div below it: <div id="map_area"> <div id="map_canvas"></div> </div> <div id="date_range"> <input type="text" id= ...

Configuring a background logo in WordPress using the Redux framework

I am attempting to integrate a "Logo upload" theme option using Redux framework, but I encountered an issue due to the logo being set up through a stylesheet in my HTML template. How can I configure this logo using an uploader? As a newcomer to WordPress a ...

Utilizing the power of Bootstrap, you can create a row of eye-catching

I am struggling to get 3 columns of cards to display in a row using bootstrap and CSS. Currently, only 2 columns are showing up. Here is the code snippet: <style type="text/css"> .card{ width: 350px; } </style> ...

How to Display Full Lightbox Image on both Tall and Short Height Browsers

Hey there! I'm showcasing my portfolio using lightbox, but I've run into a little issue. When the browser height is full, everything looks great - you can see the entire image, along with the paragraph and buttons. https://i.stack.imgur.com/UCJG ...

Content missing after centered banner

Seeking help! I need to figure out how to center text after a container. Whenever I try, it ends up either behind the banner picture or misaligned. I want both the banner and the text example to be centered, but placing the text in the right position has b ...

What is the best way to accept user input in typescript?

Currently, I am working on a TypeScript project that involves taking user input for the addition of two numbers. Below is the code snippet I am using: function rotatedString(S1,S2){ return S1+S2; } function processData() { //INPUT[uncomment & m ...

Design your own custom up and down arrow icons or buttons using CSS styling techniques

Is there a way to create "up and down" control buttons using only CSS and no background image? I attempted to add CSS for arrows in "li.className:after or li.className:before", but it caused the main boxes to move. Check out the Fiddle link to see the is ...

Ensure that the div stays in the same position regardless of the screen resolution

On my webpage, I have a page header with a select menu that needs to be properly positioned on top of the background image. How can I ensure it stays in place when the screen resolution changes? Here is how it looks on a larger resolution: <div c ...

Error TS2339 occurs when attempting to migrate to TypeScript due to the absence of the 'PropTypes' property on the 'React' type

Currently in the process of converting a javascript/react project to a typescript/react/redux project. Encountering an issue with this particular file: import React from 'react'; import GoldenLayout from 'golden-layout'; import {Provi ...

I am experiencing issues with the responsiveness of my web page across various viewpoints, despite incorporating Bootstrap CDN links within the <head> tag

While coding in my VS Code editor for responsive websites, I encountered an issue where the output webpage was not as responsive as I expected. Even though I included Bootstrap CDN links in the head tag, the responsiveness did not meet my expectations. Bel ...

Trouble with search box images on Internet Explorer causing confusion

Here is the searchbox image displayed: With this code and css styling: #searchcontainer { margin: 40px 0 0 0; } .search { float: right; margin: 0; padding: 0; height: 21px; width: 310px; } .search input, .search button { mar ...

Stacked list using IE7 browser compatibility

Currently, I am facing an issue with IE7 where the list appears at the top of the submenu. Is there any solution to bring it back to its intended position? Surprisingly, this problem does not occur in IE8 or higher versions. I would greatly appreciate it i ...

Tips for adjusting the size of an image in both the vertical and horizontal axes using CSS

As a beginner in HTML, I am currently facing an issue while trying to display a set of pictures. My goal is to resize the pictures based on the current window size while maintaining the aspect ratio. Despite experimenting with various methods like using wi ...

Add flair to the elements contained within a div that has been assigned a class

What I am capable of doing: Creating HTML: <div id="test"> HELLO! <input type="text"> </div> Styling with CSS: #test { color:#F00; } #test input[type=text] { background-color:#000; } Now, if the #test is replaced with ...

Can the dimensions of a dialog be customized in Angular Material Design for Angular 5?

I am currently developing a login feature for an Angular 5 application. As part of this, I have implemented an Angular Material Design popup. Within the dialog screen, I have a specific process in place: The system checks the user's email to determi ...

Height Miscalculation: Chrome and FF encounter window dimension

There is a large application with numerous pages. When I use the console to execute console.log($(window).height()) on any page within the application, it returns the expected result: the height of the window, not the document. For instance: $(window).he ...

Ways to update the hamburger menu icon after it has been clicked

I am trying to create a hamburger style menu where the icon changes to a cross when clicked. How can I achieve this effect using JavaScript? Here is the HTML structure: <ul class="navigation"> <li class="nav-item"><a href="#">Home&l ...