My bootstrap 3.3 carousel (code taken straight from getbootstrap.com) keeps moving up to the browser top everytime I navigate/slide with the controls to the left or right.
So if the carousel is in the middle of the page, and you start sliding manually, it moves the entire page up until the carousel hits the browser top.
Example here: http://crevisio.com/branding/pLXAsNJdn
How can I correct this?
This is the code that cause the web to scroll up:
$('a[href*=#]').each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
var $target = $(this.hash), target = this.hash;
if (target) {
var targetOffset = $target.offset().top;
$(this).click(function(event) {
event.preventDefault();
$(scrollElem).animate({scrollTop: targetOffset}, 800, function() { // <== DISABLE THIS AND THE NEXT 2 LINES
location.hash = target;
});
});
}
}
});
The question is - why do you bind the click event to every A element with href attribute containing #
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With