smooth-scroll

simple smooth scrolling in the browser
git clone https://git.ce9e.org/smooth-scroll.git

commit
231d1a85f2a531d1c0ea41f040764e9bee161659
parent
8c2e8fb65473d85c0e3267d3542221b42cc230a4
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2016-11-18 17:11
smooth scoll on popstate

Diffstat

M TODO 1 -
M smooth-scroll.js 9 +++++++++

2 files changed, 9 insertions, 1 deletions


diff --git a/TODO b/TODO

@@ -1,7 +1,6 @@
    1     1 -	fixed header support
    2     2 -	standards compliant
    3     3 -	change direction mid-scroll
    4    -1 -	smooth scroll on history change (back button)
    5     4 !	merge upstream
    6     5 
    7     6 # wontfix

diff --git a/smooth-scroll.js b/smooth-scroll.js

@@ -48,6 +48,15 @@
   48    48       smoothScrollTo(scrollY);
   49    49     };
   50    50 
   -1    51     window.addEventListener('popstate', function(event) {
   -1    52       event.preventDefault();
   -1    53 
   -1    54       var selector = window.location.hash;
   -1    55       var scrollY = document.querySelector(selector).offsetTop;
   -1    56 
   -1    57       smoothScrollTo(scrollY);
   -1    58     });
   -1    59 
   51    60     var links = document.querySelectorAll('[href^="#"]');
   52    61     for (var i = 0; i < links.length; i++) {
   53    62       links[i].addEventListener('click', smoothScrollClick);