Jump to content

Hide an element on scroll

Recommended Posts

Site URL: https://www.chateaudefarcheville.com/en/home

Hello!

I'm not super good with coding but I have an idea of what I want to do with a component that I want to add on to my clients website (only on mobile so with media query). It's basically just hiding the component on scroll down, reveal when on top of the page (or when scrolling up)

Thanks in advance!

Screenshots coming here

Skärmavbild 2020-11-11 kl. 09.27.43.png

Skärmavbild 2020-11-11 kl. 09.28.18.png

Skärmavbild 2020-11-11 kl. 09.29.05.png

Link to comment

I saw you used a scroll based event here, please find and replace it with below

<script>
  $(window).scroll(function(){
  var scroll = $(window).scrollTop();
  if(scroll > 50){
    $('.language').addClass('scrollHidden');
    $('.Header').addClass('scrollNav');
  }
  else{
    $('.language').removeClass('scrollHidden');
    $('.Header').removeClass('scrollNav');
  }
});
</script>

And custom css for it

@media only screen and (max-width: 600px) {
  .language {
    transition: top .5s;
  }
  .language.scrollHidden {
    top: -10px;
  }
}

image.png.1ed53ea9e6cc5a038ed90d06f7d9eb37.png

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Lightbox Studio plugin
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.