Is there a way to initiate keyframe animations on a div but only after a high resolution image within the div has finished loading?

I am facing an issue with the keyframe animation fadeIn on my page. Currently, it runs immediately after the page is loaded, but I want it to run only after the high resolution image inside the .image div has finished loading. How can I achieve this?

Is there a jQuery solution available for this problem?

http://jsfiddle.net/mixin/6zeBF/

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
    @-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
    @-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
    @keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.image{
    opacity:0;  
    -webkit-animation:fadeIn ease-in 1; 
    -moz-animation:fadeIn ease-in 1;
    animation:fadeIn ease-in 1;
    -webkit-animation-fill-mode:forwards; 
    -moz-animation-fill-mode:forwards;
    animation-fill-mode:forwards;
    -webkit-animation-duration:1s;
    -moz-animation-duration:1s;
    animation-duration:1s;
}

<div id="content">

    <div class="image">
    <img src="http://i.imgur.com/uIn74U7.png" alt="">
    </div>

</div>

Answer №1

$(document).ready(function(){   
    $('div > div').addClass('image');
});

According to the documentation:

The load event is triggered on an element when it and all its sub-elements have finished loading. This event can be triggered on any element linked to a URL: images, scripts, frames, iframes, and the window object.

Reference: https://api.jquery.com/load-event/

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

Incorporating personalized jQuery (modal window) into a WordPress site

I created a unique jQuery modal/pop-up and now I am looking to integrate it into my WordPress site. HTML <div id="customDialog"> <form id="myForm" method="post"> <br><br><br> <p id=title name=title><b>S ...

over line up text align on the baseline with hr

I'm looking to make sure the text is positioned just above the hr tag, similar to how the logout button appears with bootstrap. This is the desired outcome: https://i.sstatic.net/gIl1b.png Here's the code I have using bootstrap : <di ...

"Looking to disable the browser shortcut for ctrl-N and instead trigger a function when this key combination is pressed? Check out the JS Fiddle example provided below

I recently incorporated the library shortcut.js from In my project, I attempted to execute a function when CTRL + N is pressed. The function executed as expected; however, since CTRL + N is a browser shortcut for opening a new window in Mozilla 8, it also ...

Why is it impossible for me to delete the class / property of this object?

Within a series of nested divs, there are additional divs containing multiple imgs. The goal is to cycle through these images using CSS transitions. To achieve this, a JavaScript object was created to track the divs, sub-divs, and images. Three arrays were ...

Size of text Including line breaks

I have developed a function that calculates the maximum size of text: function CalculateMaxTextSize(width, height, text) { var ourText = $('span').css('font-weight', 'bold').text(text); ...

Issue with styled-components not being exported

Issue: ./src/card.js There was an import error: 'Bottom' is not exported from './styles/cards.style'. card.js import React from 'react' import { Bottom, Color, Text, Image } from "./styles/cards.style"; fu ...

Adding or Deleting Rows from Input Table

I'm in the process of creating a website that features an input table allowing users to easily add or remove rows at their discretion. The desired UI is shown below: https://i.sstatic.net/EFAlM.jpg Here is the HTML code I have developed so far: & ...

Need help with jQuery UI and managing changing content?

Looking for suggestions on using a dynamic, single dialog that updates based on ajax calls. Is there a graceful method to adjust the height and width according to the new content? Currently encountering issues with an empty div being populated. Any assist ...

Trouble with displaying pagination within an iframe

I am facing an issue with the pagination in iframe where the height of the iframe does not increase according to the content when I navigate to the next page. Please see the issue demonstrated here: http://fsportal.us-east-1.elasticbeanstalk.com usernam ...

Missing jQuery data attribute value detected

I have two custom data attributes within the <option> element, which hold the latitude (lat) and longitude (lng>) for mapping purposes:</p> <pre><code><option id="riderInfo" data-lat="" data-lng=""></option> </pre ...

Having trouble understanding how to incorporate jQuery GetListItems with SharePoint SOAP - it seems simple, but can't figure it out!

I'm attempting to incorporate a SharePoint list into an Unordered List to set up a basic search function (since Sharepoint's Search functionality is quite lacking). Below is the code I found and adjusted: $(document).ready(function() { v ...

Determine the total count of files in queue with Uploadify prior to initiating the upload process

When I specify auto: false in the uploadify settings, the upload process will only start when the submit button is clicked. Once the onQueueComplete event is triggered, the form will be submitted. However, if no files are selected, the onQueueComplete even ...

At the ready stance for a particular grade of students attending a class

I have created a page with a navigation menu that can be scrolled using the wheel mouse. My goal is to ensure that the li item with the 'selected' class is always positioned in the first position on the left. Is there a way to achieve this using ...

What is the best way to manage click events on a Bootstrap table dropdown menu for adjusting column visibility?

Recently, I have been working on constructing a table using the Bootstrap Table framework. I am taking advantage of the showColumns feature to implement a dropdown menu that allows users to choose which columns to display. However, I am facing an issue wh ...

Loading a gallery dynamically using AJAX in a CakePHP application

I am currently working with Cakephp 2.8.0 and I am facing an issue with implementing ajax in my application. I have a list of categories displayed as li links, and upon clicking on a category, I need to remove certain html code, locate the necessary catego ...

Use Ajax to dynamically update the href attribute of an ID

I have a page with songs playing in a small audio player, and the songs change every 1-2 minutes or when I choose to (like a radio). Users can vote on each song using the following format: <span class='up'><a href="" class="vote" id="&l ...

jQuery script is not accessible on a page loaded via AJAX

I am facing an issue with my jQuery function that I need help resolving. The function in question is as follows: ( function( $ ) { "use strict"; var CHEF = window.CHEF || {}; CHEF.fancyTitler = function() { if( $( '.k-fancy-tit ...

code for handling window.location.href error

Continuing from the previous question, I am facing an issue with redirecting a form to an action while using Ajax. Despite my attempts to add a redirect in the Ajax function, I keep encountering errors and getting the wrong URL. The desired redirection is ...

The sole focus is on the animation within the div

Is it possible to have a circle animation within a button without overlapping it? Check out my code on this fiddle. $(document).ready(function(){ $('button').on("mouseup",function(){ $('#mousemark').removeClass("c ...

A loading bar reminiscent of the one used in Gmail

Is there a way to implement a progress bar similar to Gmail when loading content into a div element called display <div id="display"></div>? The content is fetched from an external page using jQuery $('#display').load('somepage.h ...