Slidebars
Slidebars copied to clipboard
Problem with #anchor links
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?
I think the
scrollTop: target.offset().top line should be scrollTop: $(target).offset().top
That should help you.
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.