-
AuthorPosts
-
July 10, 2022 at 1:09 pm #1357872
Dear Support,
Good day.
I would like to remove/ hide header menu and logo when the scroll down reach particular section of the window.
This changes I need only for certain pages, i.e. I have installed Table press plugin, when we scroll down to reach the window on the Tablepress Tables, the header menu bar and logo should disappear. and when scroll up it should appear/ show the menu and the logo.Please advice.
Thank you in advance.
BR
Anish AppukuttanJuly 10, 2022 at 2:52 pm #1357877Hey qhsedirectory,
Thanks for the link to your page, currently you have an error showing at the top of your page above your menu:/** Add your own functions here. You can also copy some of the theme functions into this file. * WordPress will use those functions instead of the original functions then.*/
this is the text in your child theme functions.php, please try removing any changes that you have made to correct.
As for hiding and showing the header when a specific place on the page is in view, I tested on an example page containing many columns with text blocks, and for one text block I added a custom class waypoint-trigger:
this “trigger” element is down a ways on the page so it is not in view on the page load:
then I added this css in the Enfold Theme Options ▸ General Styling ▸ Quick CSS field:.waypoint-hide { position: fixed !important; top: -100px; width: 100%; z-index: 999; opacity: 0; background: #fff; transition: 0.3s all; box-shadow: 0 2px 3px rgba(0,0,0,0.15); } .waypoint-show { top: 0; opacity: 1; transition: 0.3s all; }
and this code in the child theme functions.php file in WordPress ▸ Appearance ▸ Editor:
function custom_waypoint_trigger_script() { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function($){ var $header = $('#header_main'); var $things = $('.waypoint-trigger'); $things.waypoint(function(direction) { if (direction === 'down') { $header.addClass('waypoint-hide'); $header.removeClass('waypoint-show'); } if (direction === 'up') { $header.addClass('waypoint-show'); $header.removeClass('waypoint-hide'); } }, { offset: '95%' }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'custom_waypoint_trigger_script');
Note in the script the “offset” is 95%, this will trigger when the element is just in view, you can adjust to suit, such as 50% for when the element is in the middle of the page.
Please give this a try, I linked to my example page below.Best regards,
MikeJuly 10, 2022 at 5:35 pm #1357884This reply has been marked as private.July 10, 2022 at 6:36 pm #1357887Hi,
Thank you for the login to your site I believe the issue was that your child theme functions.php was missing the top <?php
I added it back and the script and the css to your child theme stylesheet.
I also adjusted the offset to 10% so the header hides just before the table gets to it.
Please clear your browser cache and check.Best regards,
MikeJuly 11, 2022 at 10:56 am #1357916Dear Mike,
Good day.Thank you so much for the script, it is working perfect, the way I want.
I have adjusted other settings accordingly, now the tablepress content and the heading visible on the full page.You can close this ticket.
Thank you once again.BR
Anish AppukuttanJuly 11, 2022 at 11:43 am #1357924Hi,
Great, I’m glad that Mike could help you out. I’ll close this thread for now then, please open a new thread if you should have any further questions or problems.
Best regards,
Rikard -
AuthorPosts
- The topic ‘Hide top menu and logo, when the scroll reach on particular section.’ is closed to new replies.