Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Carousel keeps moving up when sliding control left or right

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?

like image 861
rainerbrunotte Avatar asked Oct 20 '22 15:10

rainerbrunotte


1 Answers

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 #?

like image 136
Alon Eitan Avatar answered Oct 24 '22 14:10

Alon Eitan