This could be super useful for things like navbars
http://codepen.io/IamManchanda/pen/VPZMba
Simple "smooth-scroll" class on anchor tags
Here is the simple javascript ( jquery ) code
$('a.smooth-scroll[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
Source: CSS Tricks
Update : I am not looking for any plugin, only simple basic smooth scroll for basic landing page functionality specifically for navbars and simple anchor tags which will help to scroll the page smoothly.
I believe we have discussed this in the past and have settled on recommending other plugins for this. CC @mdo @cvrebert
@hnrch02 oh i see, is there any issue with the code ?
I am asking this because why would you need a plugin if you can do a thing in a 10 liner code
I assumed you were suggesting that we add a plugin 脿 la ScrollSpy or Tooltip for this functionality. Then we would need to write a lot more than 10 lines of code, since it would need extensive unit testing too 馃槃
@hnrch02 nah nah only basic smooth scroll ... basic landing page functionality specifically for navbars and simple anchor tags. Simple "smooth-scroll" class on anchor tag which will help to scroll the page smoothly.
For example: https://blackrockdigital.github.io/startbootstrap-scrolling-nav/
Passing on this.
Any specific Reasons @mdo.. Simple code ... No plugins
I'm not a huge fan of hijacking or modifying scrolling, don't feel it's a useful application of our time, doesn't help solve any glaring issues with the framework, etc. I'd sooner see us remove or simplify things than add more to the core.
Just because we _can_ add something, doesn't mean we _should_.
Generally (depending on technique) messing with scrolling can also negatively impact things like hardware acceleration.
This is certainly something that would be more of a fit as a plugin/extension/addon, rather than core bootstrap.
Ohk no issue @mdo sir @patrickhlauke sir
But I have to say with most systems and mobile's being new and updated these days, I don't see " that " much hardware acceleration issues Patrick sir