Skip to content

Simple theme: A CSS trick for a smooth disappearance of the menu when scrolling ? #1825

Answered by Vinc26
Vinc26 asked this question in Help
Discussion options

You must be logged in to vote

Finally I found a simple solution!

The original Simple Theme is also using javascript to add/hide a .sticky class when scrolling.

In the https://labs.semplice.com/headroom-js page, there is a link to the solution https://help.semplice.com/hc/en-us/articles/360028553851-Hide-reveal-sticky-navigation-on-scroll

Here is how I've adapted it to Simple Theme:

1 - Load jQuery by adding custom HTML in Head:

<script type='text/javascript' src="https://mywebsite.com/jquery-3.7.1.min.js"></script>

2 - Add this custom HTML to Footer:

$(function() {
  var prev = 0;
  var $window = $(window);
  var nav = $('.top');

  $window.on('scroll', function(){
	var scrollTop = $window.scrollTop();
	nav.toggleCla…

Replies: 5 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@michaelfluegge
Comment options

@Vinc26
Comment options

Comment options

You must be logged in to vote
1 reply
@michaelfluegge
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Vinc26
Comment options

You must be logged in to vote
1 reply
@Vinc26
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants