Ajouter un loader en jQuery
2019-05-14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Dans le HTML --> | |
<div class="page_loader"> | |
<div id="inner"> | |
<img src="chemindugifanime.gif" alt="loader" /> | |
</div> | |
</div> | |
<!--Trouver un loader gif ? | |
Ici, par exemple : https://loading.io/ | |
--> | |
/**Dans la CSS, exemple de style en full page**/ | |
.page_loader{display:table; width:100%;height:100%;position:absolute;top:0;left:0;} | |
#inner{display:table-cell;width:100%;height:100%;height:100vh;vertical-align:middle;} | |
//Dans le fichier js (avant document ready function, tout en haut du fichier) ou dans la page HTML tout en bas a près l'appel du jQuery | |
//Exemple 1: animation vers le haut | |
<script type="text/javascript"> | |
$(window).load(function() { | |
$(".page_loader").fadeOut("slow").animate({top:-1600},1200); | |
}); | |
</script> | |
//Exemple 2: fondu | |
<script type="text/javascript"> | |
$(window).load(function() { | |
$(".page_loader").fadeOut("slow") | |
}); | |
</script> | |
<!-- Exemple sur Codrops --> | |
https://tympanus.net/codrops/tag/preloader/ | |
https://tympanus.net/Development/CreativeLoadingEffects/ | |
<!-- Autre ressources --> | |
https://www.w3schools.com/howto/howto_css_loader.asp | |
https://css-tricks.com/css-page-loader/ | |
https://techsini.com/how-to-add-css-preloader-to-your-website-tutorial/ | |
https://medium.muz.li/top-30-most-captivating-preloaders-for-your-website-95ed1beff99d?gi=34095f4a2de0 |