]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fixed #8715
authorJacob Thornton <jacobthornton@gmail.com>
Mon, 29 Jul 2013 05:23:20 +0000 (22:23 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Mon, 29 Jul 2013 05:23:20 +0000 (22:23 -0700)
assets/js/application.js

index bff00fc331d2f232f64d2c14cf5a8f1eded87f04..54f9455f7028a493aa109c2bf6717bd1e81b7c19 100644 (file)
@@ -7,10 +7,11 @@
   $(function(){
 
     var $window = $(window)
+    var $body   = $(document.body)
 
     var navHeight = $('.navbar').outerHeight(true) + 10
 
-    $(document.body).scrollspy({
+    $body.scrollspy({
       target: '.bs-sidebar',
       offset: navHeight
     })
       e.preventDefault()
     })
 
-    $(document.body).on('click', '.bs-sidenav [href^=#]', function (e) {
+    $body.on('click', '.bs-sidenav [href^=#]', function (e) {
       var $target = $(this.getAttribute('href'))
 
-      // e.preventDefault() // prevent browser scroll
+      e.preventDefault() // prevent browser scroll
 
-      document.body.scrollTop =
-        $target.offset().top -
-        navHeight + 5 // offset scroll by nav
+      $window.scrollTop($target.offset().top - navHeight + 5)
     })
 
     // back to top