load a fading div on resizing
I want to load a preloader on resizing
the HTML
- <div id="preloader"></div>
the CSS
- #preloader{
- width:100vw;
- height:100vh;
- z-index:9999;
- background:@black;
- position:absolute;
- top:0;
- left:0;
- text-align:center;
- opacity:0;
- display:none;
- }
When resizing and when the html total (viewport) width cross the size 1440px 1024px 768px
I would like to set the opacity : 1 and display:block; for the #preloader with a 0.5second fading effect
I cannot find a good way to do that
- function runPreloader() {
- $("#-preloader").delay(100).fadeOut(700);
- $('body').animate({ opacity: 1}, 700, function() {});
- }
- var $ww = $(window).innerWidth();
- var $widths = [ 1400,1280,768 ];
- $(window).resize(
- $.each( $widths, function( $key, $val ) {
- if($ww == $val){
- runPreloader;
- }
-
- });
- );
thanks for your help