DroidPinkman
3/23/2019 - 11:37 PM

Vanialla Sticky

Custom sticky scroll script. Fit to suite or use as a foundation.

var $ao_body         = $('body'),
	 $languages_height = $(el).height(),
	 scroll_start      = 1300;

function addStickyClasses() {
	$(el).addClass('is-scrolled');
}

function removeStickyClasses() {
	$(el).removeClass('is-scrolled');
}

function stickyResize() {
	if($(window).width() < scroll_start) {
		removeStickyClasses();
	}
}

function stickyHeader() {
	var wst = $(window).scrollTop();

	if( $(window).width() >= scroll_start ) {
		var offset_item 		= $(el).offset().top - wst,
				content_offset	= $(el).offset().top - wst;

		if(wst >= $languages_height) {
			$(thing).addClass('is-pinned');
		} else {
			$(thing).removeClass('is-pinned');
		}

		if ( content_offset <= other_offset ) {
			addStickyClasses();
		} else {
			removeStickyClasses();
		}
	}
}

if (window.matchMedia("(min-width: 1080px)").matches) {
	stickyHeader();
	$(window).on('scroll', stickyHeader);
}

$(window).resize(stickyResize);