Scroll to hide/Show
-
Hi,
I have made the changes according to your suggestion here;
https://wordpress.org/support/topic/no-id-for-bottom-menu-element/
However there is an error on the Browser console;
(index):5166 Uncaught TypeError: Cannot read properties of null (reading ‘style’)
at window.onscroll ((index):5166:46)
Is is about this CSS style:
.style.bottom = “-50px”;Could you please check my code and tell me what I did wrong?
CSS
#wp-bottom-menu{ position: fixed; bottom: 0; width: 100%; transition: bottom 0.3s; }
JAVA
/*wp-bottom-menu-hide-show-on-scroll*/ function wpb_hook_javascript_footer() { ?> <script> var prevScrollpos = window.pageYOffset; window.onscroll = function() { var currentScrollPos = window.pageYOffset; if (prevScrollpos > currentScrollPos) { document.getElementById("wp-bottom-menu").style.bottom = "0"; } else { document.getElementById("wp-bottom-menu").style.bottom = "-50px"; } prevScrollpos = currentScrollPos; } </script> <?php } add_action('wp_footer', 'wpb_hook_javascript_footer');
Thank you
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Scroll to hide/Show’ is closed to new replies.