Created
February 24, 2017 12:43
-
-
Save Jan-Ka/48a151e4b99df5e63512e73e1fcffbf1 to your computer and use it in GitHub Desktop.
Create a div that is set to Number.MAX_SAFE_INTEGER (fallback to Number.MAX_VALUE) to see how far it will be rendered
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
| (function () { | |
| console.log("maxWidth test running"); | |
| // in calling HTML - ensure that a div with id jsTest is available | |
| let maxWidthDiv = document.querySelector("#jsTest"); | |
| let maxWidthVal = "1337px"; | |
| if(Number.MAX_SAFE_INTEGER) { | |
| maxWidthVal = Number.MAX_SAFE_INTEGER.toString() + "px"; | |
| } else { | |
| maxWidthVal = Number.MAX_VALUE.toString() + "px"; | |
| } | |
| maxWidthDiv.style.width = maxWidthVal; | |
| // IE11 wines about String Interpolation | |
| // console.log(`element #jsTest is now set to a width of ${Number.MAX_SAFE_INTEGER}px`); | |
| console.log("element #jsTest is now set to a width of " + maxWidthVal); | |
| let lastKnownScrollPosition = 0; | |
| let ticking = false; | |
| window.addEventListener("scroll", function () { | |
| lastKnownScrollPosition = window.pageXOffset; | |
| if (!ticking) { | |
| window.requestAnimationFrame(function () { | |
| // console.log(`scrolled to: ${lastKnownScrollPosition}px`); | |
| console.log("scrolled to: " + lastKnownScrollPosition.toString() + "px"); | |
| ticking = false; | |
| }); | |
| } | |
| ticking = true; | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment