Search code examples
jqueryscrolltosticky

ScrollTo plugin - how to prevent scrolling to element being overlapped by sticky menu


I have a single page site with scrollTo plugin (by Ariel Flesler) navigation. This works perfect as far as I keep my menu in static or relative position. But when it is sticky (fixed to top), navigation goes to an element which at the same time is covered by sticky menu.

Is it possible to scroll to an element smoothly and add some pixels to prevent this element from being covered by sticky menu. Would appreciate yor help

Here is my code:

jQuery(function($) {    
    //Single Page menu - zapiętę z plaginu ScrollTo
    $("#omnie").click(function() {
    $("body").scrollTo(".omnie", 800);

});
$("#experience").click(function() {
    $("body").scrollTo(".experience", 800);
});
$("#zabiegi").click(function() {
    $("body").scrollTo(".zabiegi", 800);
});
$("#kontakt").click(function() {
    $("body").scrollTo(".kontakt", 800);
});

Solution

  • ok - found it myself. $("#omnie").click(function() { $('html, body').animate({ scrollTop: $(".omnie").offset().top - 86 }, 800); });