Pegues
Pegues

Reputation: 1773

Why is the jQuery smooth scroll jumping on the page?

I have a jQuery smooth scroll on the following page:

http://test4.coretechs.com/coretechs_site/promo-test

When you click one of the navigation items, it will scroll animate to the <div id=''> for that navigation item. The animated scroll works, but most of the time there is a jump on the page before the scrolling happens.

I'm experiencing this problem in Firefox and Chrome.

Does anyone have any idea why this jumping is occurring?

Upvotes: 0

Views: 356

Answers (1)

Try event.preventDefault()

$("ul.menu a.promonav_services, ul.menu a.promonav_portfolio, ul.menu a.promonav_contact").click(function (e) {
    e.preventdefault(); //stop the default behavior of anchor tag
    var href = $(this).attr('href').replace('#', '');
    scrollToAnchor(href);
});

Upvotes: 1

Related Questions