An impressive animation feature when presenting

I'm working on a code where I need to implement a small animation in JavaScript for displaying an element with a delay after a certain function. Here's what I have so far:

function OpenPanelEdit() {
    const element = document.getElementsByClassName("menu-on-center-edit");
    for(const i=0; i < element.length; i++) {
        element[i].style.display = 'flex';
    }
};

Does anyone have any ideas on how to accomplish this?

Answer №1

To apply the element's animation, you can set it using el.style.animation.

function DisplayPanelEdit() {
    const elements = document.getElementsByClassName("menu-on-center-edit");
    for(let i=0; i < elements.length; i++) {
        elements[i].style.display = 'flex';
        elements[i].style.animation = 'customAnimation 1s';
    }
};

You can define the animation in CSS like this:

@keyframes customAnimation {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
}

If you need to execute a function when the animation completes, you can use setTimeout:

function DisplayPanelEdit() {
    const elements = document.getElementsByClassName("menu-on-center-edit");
    for(let i=0; i < elements.length; i++) {
        elements[i].style.display = 'flex';
        elements[i].style.animation = 'customAnimation 1s';
        window.setTimeout(() => {
          runCustomFunction();
        }, 1000);
    }
};

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

After a PHP script is executed, a Bootstrap modal will automatically appear on the same page

Seeking assistance with integrating a bootstrap modal into a contact form submission. Despite multiple attempts, I have been unsuccessful in achieving this integration and now find myself at an impasse. My objective is simple: Upon clicking the submit bu ...

Unable to accommodate data within the fixed width confines of the GridView cell

I am having a column in my table with lengthy text that requires scrolling to see the end. Is there a way to adjust the content to fit within a fixed-width cell? Here is the UI setup for the GridView: <asp:GridView ID="GridView1" runat="server" OnPag ...

Crafting a Knob Cursor with CSS and AngularJS for a Unique User Experience

After experimenting with the jQuery Knob framework, I encountered challenges when trying to incorporate AngularJS dynamic values. As a result, I opted to create my own CSS-based arc/knobs. The knob displays three values: minimum, maximum, and current valu ...

Executing a method from a callback within the data() function in Vue 2.7 – Here's how!

This component uses a third-party module known as HelloWorld. This module has a prop called closeCallbacks, which is an array of callbacks that are triggered when the HelloWorld component is closed. Unfortunately, the functionality of the third-party comp ...

Removing an item with Ajax upon page reload

After creating a small Ajax script to remove items from my database and view, I encountered an issue where the view was only updated after a reload when the item was removed. I want to avoid reloading the entire page by using window.location.reload() in m ...

Add an element following an HTML dropdown menu and gradually fade it away

Is there a way to make an img element appear right after a select and fade out? Methods I've experimented with: appendTo isn't suitable since it places elements inside the select element. Using after requires calling it from the select element ...

What could be the reason behind my jQuery UI buttons suddenly appearing oversized and lackluster?

Previously, I utilized the jQuery UI to enhance button appearance. However, with this code snippet: else if (ui.newTab.index() == 3) { $('#MediaContent').load('Content/TwainMedia.html'); $('#MediaContent').css('b ...

Ways to conceal the horizontal scroll bar that appears along the bottom of an HTML page

There is an annoying horizontal scroll bar appearing at the bottom of my HTML page: https://i.sstatic.net/n0sNw.png I have attempted to fix it using this code snippet: body { width: 900px; margin: auto; overflow-x: hidden; } Unfortunately, t ...

Turn off images using Selenium Python

In order to speed up the process, I believe that disabling images, CSS, and JavaScript can help since Webdriver waits for the entire page to load before moving on. from selenium import webdriver from selenium.webdriver.firefox.firefox_profile import Firef ...

Script for migrating MongoDB attributes to an array

I am in the process of creating a database migration, and the current structure is as follows: { "site" : { "name" : "siteName1" }, "subStages" : [ "subStage1", "s ...

Updating form validation: relocating error messages

When using a jQuery form validation script, an "OK!" message is typically displayed below the input field when the input is correct. However, I would like to customize this behavior and have the "OK!" message appear on the right side of the field instead ( ...

Looking to enhance the size of pagination icons for previous and next pages on a Material-UI React table?

I am looking to adjust the size of the previous page and next page icons in a material table implemented in React. Below is the code snippet: localization = { { body : {} , toolbar: { searchTooltip: 'Search'} , pagination: ...

Navigating through each element of an array individually by using the onClick function in React

I'm currently working on a project that involves creating a button to cycle through different themes when pressed. The goal is for the button to display each theme in sequence and loop back to the beginning after reaching the last one. I've imple ...

Fluid carousel and dynamic loading

Currently, I am experiencing an issue with the Liquid Slider while using ajax, specifically related to height. Below is the script I am using: var api2 = $.data( $('#slider-7')[0], 'liquidSlider'); $.ajax({ complete: function( ...

Numerical values are not considered by the JavaScript table filter

I'm having trouble with dynamically filtering the content. It works fine for the first two columns, but not for the third one. Maybe I need some additional JavaScript? Here is the link to my snippet: `https://www.w3schools.com/code/tryit.asp?filen ...

Opacity problem when hovering on Chrome

Work in progress: Hello everyone, I'm facing an issue with a hover effect that only seems to be occurring in Chrome. When hovering over a tile, the background color changes, the image opacity decreases, and an icon appears over the image. In Chro ...

Having trouble getting Node.js, express, socket.io, and ejs to work together?

Currently, I am working on improving my knowledge of java-script and had the idea to create a basic chat app using Express, stock.io, and ejs. Unfortunately, I am facing some challenges in getting it up and running smoothly. Below is the snippet from my ...

Stylish Card Design

Below is the CSS code: *{margin:0; padding:0; box-sizing:border-box; } img{ display:block; max-width:100%; height:auto; } html{ scroll-behavior:smooth; } body{ min-height:100vh; font-family:fantasy; font-size:1.12 ...

Enhance Your Website with HTML and JavaScript

Here is the code snippet I am working with: sTAT **javascript** var acc = document.getElementsByClassName("item-wrapper"); var i; for (i = 0; i < acc.length; i++) { acc[i].onclick = function(){ this.classList.toggle("selected"); this.nextElementS ...

issue with accessing the code through the web browser

Currently, I am developing a web application using ASP.NET MVC5. I have been coding and pushing my work to GitHub. However, I recently encountered an issue where I can no longer view my application on the browser. The "View in browser" option has disappear ...