Skip to content

Instantly share code, notes, and snippets.

@o0
Last active May 5, 2020 14:24

Revisions

  1. o0 renamed this gist May 5, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. o0 created this gist May 5, 2020.
    5 changes: 5 additions & 0 deletions scroll-background.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    let sectionToAnimate = document.querySelector('.section_special');

    window.addEventListener('scroll', function() {
    sectionToAnimate.style.backgroundPosition = `-${document.body.scrollTop}px 0`;
    });