mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-12 16:54:00 +02:00
Cache navLinks and filter for performance
This commit is contained in:
@@ -31,7 +31,8 @@
|
|||||||
//console.log("They see me scrollin, they hatin");
|
//console.log("They see me scrollin, they hatin");
|
||||||
|
|
||||||
//clear highlighting
|
//clear highlighting
|
||||||
$('.site-navigation a').removeClass("active");
|
var navLinks=$('.site-navigation a')
|
||||||
|
navLinks.removeClass("active");
|
||||||
|
|
||||||
//calc current viewport
|
//calc current viewport
|
||||||
var viewTop = $(window).scrollTop();
|
var viewTop = $(window).scrollTop();
|
||||||
@@ -45,7 +46,8 @@
|
|||||||
var eBottom = eTop + $(e).height();
|
var eBottom = eTop + $(e).height();
|
||||||
if (eTop >= viewTop) {
|
if (eTop >= viewTop) {
|
||||||
if (eBottom <= viewBottom) {
|
if (eBottom <= viewBottom) {
|
||||||
$('.site-navigation a[href="/#'+e.id+'"]').addClass("active");
|
//filter cached navLinks
|
||||||
|
navLinks.filter('[href="/#'+e.id+'"]').addClass("active");
|
||||||
} else {
|
} else {
|
||||||
//console.log("Start skipping test with "+e.id);
|
//console.log("Start skipping test with "+e.id);
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user