Skip to content

Instantly share code, notes, and snippets.

@BroFox86
Last active May 30, 2024 11:42
Show Gist options
  • Save BroFox86/8214b9d7aa1a1119ef304011256a612d to your computer and use it in GitHub Desktop.
Save BroFox86/8214b9d7aa1a1119ef304011256a612d to your computer and use it in GitHub Desktop.

Revisions

  1. BroFox86 revised this gist May 30, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion snippet.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    function listenResize() {
    function listenWindowResize() {
    let width = window.innerWidth;
    let allowReset = true;

  2. BroFox86 revised this gist May 30, 2024. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions snippet.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,14 @@
    function listenResize() {
    let width = window.innerWidth;
    let allowReset = true;

    window.addEventListener("resize", () => {
    if (width === window.innerWidth) {
    return;
    }

    width = window.innerWidth;

    if (!allowReset) {
    return;
    }
  3. BroFox86 revised this gist May 28, 2024. No changes.
  4. BroFox86 created this gist May 28, 2024.
    17 changes: 17 additions & 0 deletions snippet.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    function listenResize() {
    let allowReset = true;

    window.addEventListener("resize", () => {
    if (!allowReset) {
    return;
    }

    allowReset = false;

    setTimeout(() => {
    allowReset = true;
    }, 1000);

    // Code...
    });
    }