Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from hmowais/custom.js
Created July 25, 2025 10:08
Show Gist options
  • Select an option

  • Save dexit/fee42d380c0450fa6b62e8f90d8281a9 to your computer and use it in GitHub Desktop.

Select an option

Save dexit/fee42d380c0450fa6b62e8f90d8281a9 to your computer and use it in GitHub Desktop.
Add Class in Section on Scroll
jQuery( document ).ready(function($) {
var sections = $('.animateiT'),
nav = $('.jump-left'),
nav_height = nav.outerHeight();
$(window).on('scroll', function() {
var cur_pos = $(this).scrollTop();
sections.each(function() {
var top = $(this).offset().top - 300;
var bottom = top + $(this).outerHeight();
if (cur_pos >= top && cur_pos <= bottom) {
nav.find('a').removeClass('animated-div');
sections.removeClass('animated-div');
$(this).addClass('animated-div');
nav.find('a[href="#' + $(this).attr('id') + '"]').addClass('animated-div');
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment