-
AuthorPosts
-
November 30, 2019 at 1:38 am #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
IngoDecember 1, 2019 at 12:34 am #1161520My 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 yourselfDecember 2, 2019 at 6:03 am #1161735Hi,
Thanks for sharing and for helping out @guenni007, did you try that out and did you have any luck with it @inbu1012?
Best regards,
RikardDecember 3, 2019 at 1:09 am #1162038This reply has been marked as private.December 3, 2019 at 1:24 am #1162039Dear Guenni007,
great! I pasted your code in functions.php and it worked immediatly.
I thank you very much!
Best regards
IngoDecember 3, 2019 at 2:16 am #1162042Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Menu bar with dynamically changing colors referencing the background’ is closed to new replies.