Slidebars icon indicating copy to clipboard operation
Slidebars copied to clipboard

Problem with #anchor links

Open NoLooseEnds opened this issue 8 years ago • 2 comments

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 );
} ); 
  • It jumps to the anchor point, but no smooth scrolling.
  • Other anchor links not in the Slidebars don't work.
  • I got an compiling error on "target.offset().top;". Changing it to "," or nothing let's it compile.

Any help around this issue?

NoLooseEnds avatar Feb 23 '17 14:02 NoLooseEnds

I think the

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

That should help you.

cernyjakub avatar Feb 23 '17 14:02 cernyjakub

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.

NoLooseEnds avatar Feb 23 '17 14:02 NoLooseEnds