Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. (function () {
  2. console.log("maxWidth test running");
  3.  
  4. // in calling HTML - ensure that a div with id jsTest is available
  5. let maxWidthDiv = document.querySelector("#jsTest");
  6. let maxWidthVal = "1337px";
  7.  
  8. if(Number.MAX_SAFE_INTEGER) {
  9. maxWidthVal = Number.MAX_SAFE_INTEGER.toString() + "px";
  10. } else {
  11. maxWidthVal = Number.MAX_VALUE.toString() + "px";
  12. }
  13.  
  14. maxWidthDiv.style.width = maxWidthVal;
  15.  
  16. // IE11 wines about String Interpolation
  17. // console.log(`element #jsTest is now set to a width of ${Number.MAX_SAFE_INTEGER}px`);
  18. console.log("element #jsTest is now set to a width of " + maxWidthVal);
  19.  
  20. let lastKnownScrollPosition = 0;
  21. let ticking = false;
  22.  
  23. window.addEventListener("scroll", function () {
  24. lastKnownScrollPosition = window.pageXOffset;
  25.  
  26. if (!ticking) {
  27. window.requestAnimationFrame(function () {
  28. // console.log(`scrolled to: ${lastKnownScrollPosition}px`);
  29. console.log("scrolled to: " + lastKnownScrollPosition.toString() + "px");
  30. ticking = false;
  31. });
  32. }
  33.  
  34. ticking = true;
  35. });
  36. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement