Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Srinivasan Pusuluri
Added: Oct 20, 2020 7:13 AM
Views: 11
Tags: no tags
  1. document.body.classList.add('js-loading');
  2.  
  3. window.addEventListener("load", showPage);
  4.  
  5. function showPage() {
  6.   document.body.classList.remove('js-loading');
  7. }
  8.  
  9. var img = document.querySelector("img");
  10. document.body.classList.add('js-loading');
  11. img.addEventListener("load", removeLoadingClass);
  12. function removeLoadingClass() {
  13.   document.body.classList.remove('js-loading');
  14. }
  15.  
  16. .js-loading *,
  17. .js-loading *:before,
  18. .js-loading *:after {
  19.   animation-play-state: paused !important;
  20. }