Jump to content

michaelbaillot

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by michaelbaillot

  1. Hi, I've tried to add a breakpoint following this link. I'm wondering if it's well set. The only value I get is currentScrollPos=0…
  2. As you cas see below, I've tried several tests: some are partly working, others not at all… <!-- script permettant de gérer l'affichage du header en fcontion du scroll <script> var prevScrollpos = window.pageYOffset; window.onscroll = function() { var currentScrollPos = window.pageYOffset; if (prevScrollpos > currentScrollPos) { document.getElementById("navbar").style.top = "0"; } else { document.getElementById("navbar").style.top = "-180px"; } prevScrollpos = currentScrollPos; } </script> --> <!-- V2 // script permettant de gérer l'affichage du header en fcontion du scroll <script> window.onscroll = function() { if (document.body.scrollTop > 180 || document.documentElement.scrollTop > 180) { document.getElementById("navbar").style.top = "-180px"; } else { document.getElementById("navbar").style.top = "0"; } } </script> --> <!-- V3 // script permettant de gérer l'affichage du header en fcontion du scroll <script> var prevScrollpos = window.pageYOffset; window.onscroll = function() { if (document.body.scrollTop > 180 || document.documentElement.scrollTop > 180) { document.getElementById("navbar").style.top = "-180px"; } else { document.getElementById("navbar").style.top = "0"; var currentScrollPos = window.pageYOffset; if (prevScrollpos > currentScrollPos) { document.getElementById("navbar").style.top = "0"; } else { document.getElementById("navbar").style.top = "-180px"; } prevScrollpos = currentScrollPos; } } </script> -->
  3. Well, as you can see online, nothing happens… Thanks, best, Michael
  4. Hi w3schools, thanks for your amazing website. I tried to mix two of your "how to" scripts (Hide Menu on Scroll and Shrink Navigation Menu on Scroll) so that my navbar hide after 180px from top. But… I'm not a coder, I try to learn and it doesn't work for the moment: <script> var prevScrollpos = window.pageYOffset; window.onscroll = function() { var currentScrollPos = window.pageYOffset; if (document.body.scrollTop < 180 || document.documentElement.scrollTop < 180 || prevScrollpos > currentScrollPos) { document.getElementById("navbar").style.top = "0"; } else { document.getElementById("navbar").style.top = "-180px"; } prevScrollpos = currentScrollPos; } </script> Any ideas? Thanks a lot, Best, Michael best regards, Michael Website: https://www.schema-studio.ch/
×
×
  • Create New...