adchsm / Slidebars

Slidebars is a jQuery Framework for Off-Canvas Menus and Sidebars into your website or web app.
http://www.adchsm.com/slidebars/
MIT License
1.5k stars 307 forks source link

Problem with #anchor links #275

Open NoLooseEnds opened 7 years ago

NoLooseEnds commented 7 years ago

Hi, a couple of problems with anchor links.

By using JS provided in the advanced help section

$( 'a[href^="#"]' ).on( 'click', function( event ) {
  event.preventDefault();

  var target = $( this ).attr( 'href' );

  $( '[canvas="container"]' ).animate( {
    scrollTop: target.offset().top,
  }, 1000 );
} ); 

Any help around this issue?

cernyjakub commented 7 years ago

I think the

scrollTop: target.offset().top line should be scrollTop: $(target).offset().top

That should help you.

NoLooseEnds commented 7 years ago

Thanks, but it did not change any behaviour. It still jumps to the anchor, no smooth scroll.

(and not the other normal – non slidebar – anchor links does not work at all – I guess that is the biggest issue.)

EDIT: It actually did change the behaviour on non-sidebar anchor links. They work with smooth scrolling.

Thank you.