window resize event

In this example below you will see how to do a window resize event with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by FlotDag, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright FlotDag ©
  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>window resize event</title>
  
  
  
      <style>
      /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */
      body {
  background-color: #000;
}

    </style>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>

</head>

<body>

  
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/FlotDag/window-resize-event-aBBvgN */
body {
  background-color: #000;
}


/*Downloaded from https://www.codeseek.co/FlotDag/window-resize-event-aBBvgN */
var resizeTimer;

$(function(){
  $(window).on('resize', function(){
    clearTimeout(resizeTimer);
    resizeTimer = setTimeout(function(){
      console.log('resize done');
    }, 250);
  })
})

Comments