Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1161421

    Hi Kriesi Team,
    I’m using Enfold and I am very happy with it.
    I found a functonality on the site https://website-coach.at/ where the color of the menu bar is changing according to its background.
    It is a single site. This means there are not different menu bars for different pages. There is probable one menu with this property.

    Do you know a way to build this functionality on an Enfold site?
    Best regards
    Ingo

    #1161520

    My first thought was to use the waypoints script. Enfold has on default implemented the waypoints script.
    You can google to its functionality.

    if you have defined for the color-section background-colors. You can use it to give that color to the header_bg background-color:
    see here: https://webers-testseite.de/datenschutzerklaerung/

    this comes to child-theme functions.php:

    function header_bg_color_on_scroll() {
    ?>
    <script>
        (function($) {
        var element_to_animate = $('.avia-section');
    
        element_to_animate.waypoint(function(direction) {
        if (direction === 'down') {
            var section_color = $(this.element).css('background-color');
              $('.header_bg').css('background-color', section_color);
            }
            }, {
              offset: '100px'
            });   
        element_to_animate.waypoint(function(direction) {
        if (direction === 'up') {
            var section_color_prev = $(this.element).prev().css('background-color');
            $('.header_bg').css('background-color', section_color_prev);
              }
            }, {
              offset: '100px'
            });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'header_bg_color_on_scroll', 9999);

    The Offset depends on your header height in scrolled mode – so if you have a shrinking header it will be the end height after scroll.
    You can test it yourself

    #1161735

    Hi,

    Thanks for sharing and for helping out @guenni007, did you try that out and did you have any luck with it @inbu1012?

    Best regards,
    Rikard

    #1162038
    This reply has been marked as private.
    #1162039

    Dear Guenni007,
    great! I pasted your code in functions.php and it worked immediatly.
    I thank you very much!
    Best regards
    Ingo

    #1162042

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Menu bar with dynamically changing colors referencing the background’ is closed to new replies.