bratsun
2/24/2015 - 8:42 AM

Show scroll to top link based on current scroll position on a page which height is at least X times higher than viewport.

Show scroll to top link based on current scroll position on a page which height is at least X times higher than viewport.

function scrollTopLink(pos) {
	var dH = $(document).height(),
			wH = $(window).height(),
			t = $('.scroll-to-top');
	if (pos > (dH*0.7) && dH > (wH * 1.5)) {
		t.addClass('show');
	} 
	if (pos < (dH*0.7)) {
		t.removeClass('show');
	}
}