test.html 730 B

1234567891011121314151617181920212223242526272829303132
  1. <html>
  2. <head>
  3. <title>Debounce Component</title>
  4. </head>
  5. <body>
  6. Resize the window!
  7. <br>
  8. <a id='cancel' href='#'>Cancel Print</a>
  9. <br>
  10. <a id='now' href='#'>Print Now</a>
  11. <script src="build/build.js" type="text/javascript"></script>
  12. <script type="text/javascript">
  13. var debounce = require('debounce');
  14. window.onresize = debounce(resize, 2000);
  15. document.getElementById('cancel').onclick = window.onresize.clear;
  16. document.getElementById('now').onclick = printNow;
  17. function resize(e) {
  18. console.log('height', window.innerHeight);
  19. console.log('width', window.innerWidth);
  20. }
  21. function printNow(e) {
  22. window.onresize.clear();
  23. resize();
  24. }
  25. </script>
  26. </body>
  27. </html>