css - jQuery(document).ready(function(){ isn't waiting for Background Image to load first before Fadein -


i'm having trouble jquery(document).ready(function(){ - issue it's not waiting background image load first before fading in when clear cache. happens there's delay before wrapper fades in image visibly scaling down screen loads.

i'm building headway themes on wordpress.

it's making me go insane :)

css:

@-webkit-keyframes fade-in {   0%   { opacity: 0; }   100% { opacity: 1; } }  .background-image {   background: url('http://www.aliceandowl.com/wp-content/uploads/2015/03/purity-london-homepage-banner.jpg') no-repeat center center fixed;    -webkit-background-size: cover;   -moz-background-size: cover;   -o-background-size: cover;   background-size: cover;    position: absolute;   top: 0;   right: 0;   bottom: 0;   left: 0;    opacity: 0;    -webkit-animation-name: fade-in;   -webkit-animation-duration: 1s;   -webkit-animation-timing-function: ease-in;   -webkit-animation-iteration-count: 1;   -webkit-animation-delay: 2s;   -webkit-animation-fill-mode: forwards; }  .background-image.visible {   opacity: 1; } 

jquery:

  jquery(document).load(function() {   jquery('.background-image').on('webkitanimationend', function(e) {     jquery(this).addclass('visible');   }); }); 

i have tailored from: http://codepen.io/graygilmore/pen/hxpet

any solutions beyond appreciated!

thanks, danielle

i have made site live (it's under construction ha) - you'll see background image on load: http://www.aliceandowl.com guys!

so far answers given doing same thing, , issue still remains fadein doesn't wait background image load first.

$(document).ready doesn't wait resources load. makes sure callback called after dom loaded.

for resources, use $(window).load, triggers callback function when external resources js/css/images loaded.

the load event sent element when , sub-elements have been loaded. event can sent element associated url: images, scripts, frames, iframes, , window object.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -