Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #313980

    Hey Team,
    I need to change the offset of bootstrap scrollspy.

    jQuery(‘body’).data()[‘bs.scrollspy’].options.offset;

    It is set to 10 and I need it to be 50. Where is this value set? I would prefer a solution that doesn’t overwrite the already set default value.

    Thanks in advance.

    #314283

    Hey!

    Enfold uses a modified version of ScrollSpy which can be found in js/avia.js, around line 115.

    Best regards,
    Josue

    #314418

    Hey Josue,
    thanks for your reply. Ahead of my first post I tried already the following change – without success:

    avia.js:252
    I changed:
    $.fn.avia_scrollspy.defaults = {
    offset: (parseInt($(‘.html_header_sticky #main’).data(‘scroll-offset’), 10)) + ($(“.html_header_sticky #header_main_alternate”).outerHeight()) + ($(“.html_header_sticky #header_meta”).outerHeight()) + 1 + parseInt($(‘html’).css(‘margin-top’),10),
    applyClass: ‘current-menu-item’
    }

    to:

    $.fn.avia_scrollspy.defaults = {
    offset: 50,
    applyClass: ‘current-menu-item’
    }

    The offset value is still 10.

    Any suggestions?

    Thanks
    Ole

    #316575

    Hey!

    Can we see the site live with the modified function?

    Best regards,
    Devin

    #319199
    This reply has been marked as private.
    #320978
    This reply has been marked as private.
    #321658

    Hi Ole,

    Can you please create me a WordPress administrator account (or FTP)? post it here as a private reply.

    Regards,
    Josue

    #321685
    This reply has been marked as private.
    #321690

    Hey Ole!

    I’m unable to edit js/avia.js, but basically what you need to do is modify line 709 on that file:

    var target = container.offset().top - fixedMainPadding,
    

    To:

    var target = container.offset().top - fixedMainPadding + 50,
    

    That will add some space to the top when the avia_smoothscroll (617) function fires.

    Cheers!
    Josue

    #321715
    This reply has been marked as private.
    #321725

    I could note a change (but i think it did the contrary), try using a minus instead:

    var target = container.offset().top - fixedMainPadding - 50,
    

    Best regards,
    Josue

    #322917
    This reply has been marked as private.
    #323392

    Hi Ole,

    I see it now, try adding this at the very end of your theme / child theme functions.php file:

    function change_scrollspy_offset(){
    ?>
    <script>
    (function($){
        $(window).load(function() {
        	$('body').data()['bs.scrollspy'].options.offset = 88;
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'change_scrollspy_offset');

    Regards,
    Josue

    #481837

    Hi Joseue,

    Still no effect. Please check again.
    Regards
    Gigoz

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Change the offset of bs scrollspy’ is closed to new replies.