mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-06 04:08:22 +01:00
fixed #8715
This commit is contained in:
parent
a31c5cea42
commit
edaeb33816
@ -7,10 +7,11 @@
|
|||||||
$(function(){
|
$(function(){
|
||||||
|
|
||||||
var $window = $(window)
|
var $window = $(window)
|
||||||
|
var $body = $(document.body)
|
||||||
|
|
||||||
var navHeight = $('.navbar').outerHeight(true) + 10
|
var navHeight = $('.navbar').outerHeight(true) + 10
|
||||||
|
|
||||||
$(document.body).scrollspy({
|
$body.scrollspy({
|
||||||
target: '.bs-sidebar',
|
target: '.bs-sidebar',
|
||||||
offset: navHeight
|
offset: navHeight
|
||||||
})
|
})
|
||||||
@ -19,14 +20,12 @@
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
|
|
||||||
$(document.body).on('click', '.bs-sidenav [href^=#]', function (e) {
|
$body.on('click', '.bs-sidenav [href^=#]', function (e) {
|
||||||
var $target = $(this.getAttribute('href'))
|
var $target = $(this.getAttribute('href'))
|
||||||
|
|
||||||
// e.preventDefault() // prevent browser scroll
|
e.preventDefault() // prevent browser scroll
|
||||||
|
|
||||||
document.body.scrollTop =
|
$window.scrollTop($target.offset().top - navHeight + 5)
|
||||||
$target.offset().top -
|
|
||||||
navHeight + 5 // offset scroll by nav
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// back to top
|
// back to top
|
||||||
|
Loading…
x
Reference in New Issue
Block a user