-
-
Save zdimaz/d3cb1e3a4a9b207a7c3111ba2930e704 to your computer and use it in GitHub Desktop.
spy title on scroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================================== | |
// Spy category | |
// ========================================================================== | |
if (screen.width <= 720) { | |
function spyCategory() { | |
$('.spy_category_item').each( function () { | |
if ($(window).scrollTop() + $(window).height() > $(this).offset().top && $(window).scrollTop() < $(this).offset().top) { | |
var title = $(this).data("category-title"); | |
var link = $(this).data("category-link"); | |
if (title == null) { | |
$('#spy_category').hide(); | |
} else { | |
$('#spy_category').show(); | |
} | |
$('#spy_category').find("a").text(title); | |
$('#spy_category').find("a").attr("href", link); | |
return; | |
} | |
}); | |
} | |
spyCategory(); | |
$(window).on("scroll resize", function () { | |
spyCategory(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment