Skip to content

Instantly share code, notes, and snippets.

@Jan-Ka
Created February 24, 2017 12:43
Show Gist options
  • Select an option

  • Save Jan-Ka/48a151e4b99df5e63512e73e1fcffbf1 to your computer and use it in GitHub Desktop.

Select an option

Save Jan-Ka/48a151e4b99df5e63512e73e1fcffbf1 to your computer and use it in GitHub Desktop.

Revisions

  1. Jan-Ka created this gist Feb 24, 2017.
    36 changes: 36 additions & 0 deletions maxWidth-test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    (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;
    });
    })();