Created
June 9, 2017 19:25
-
-
Save kgcreative/447ad30ce4d0a883a1a80983f24e6635 to your computer and use it in GitHub Desktop.
This file contains 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
// --------------------------------------------------------------------------- | |
// Sweet Spot - Scroll Events | |
// --------------------------------------------------------------------------- | |
$(this).waypoint(function (direction) { | |
if (direction === 'down') { | |
console.log('Sweet Spot, scrolling down'); | |
console.log('Reveal Panel Contents'); | |
$this.removeAttr('data-hide-content'); | |
} else { | |
console.log('Sweet Spot, scrolling up'); | |
$this.attr('data-hide-content', 'true'); | |
} | |
}, { | |
offset: function () { | |
if (isMobileMenu === true) { | |
return ( ($(window).outerHeight() / 2) - ( -brandBarHeight + ($this.outerHeight() / 2) ) ); | |
} else { | |
return ( ($(window).outerHeight() / 2) - ( -(navHeight + brandBarHeight + 50) + ($this.outerHeight() / 2) ) ); | |
} | |
} | |
}); | |
// --------------------------------------------------------------------------- | |
// Bottom edge of element - Scroll Events | |
// --------------------------------------------------------------------------- | |
// Bottom edge of element reaches bottom of window | |
$(this).waypoint(function (direction) { | |
if (direction === 'down') { | |
console.log('Bottom of profile panel reaches the bottom of window, scrolling down'); | |
} else { | |
console.log('Bottom of profile panel reaches the bottom of window, scrolling up'); | |
} | |
}, { | |
offset: function () { | |
return ( $(window).outerHeight() - $this.outerHeight() ); | |
} | |
}); | |
// Bottom edge of element reaches bottom of top chrome | |
$(this).waypoint(function (direction) { | |
if (direction === 'down') { | |
console.log('Bottom of profile panel reaches the bottom top of chrome, scrolling down'); | |
} else { | |
console.log('Bottom of profile panel reaches the bottom top of chrome, scrolling up'); | |
} | |
}, { | |
offset: function () { | |
if (isMobileMenu === true) { | |
return ( brandBarHeight - $this.outerHeight() ); | |
} else { | |
return ( (navHeight + brandBarHeight) - $this.outerHeight() ); | |
} | |
} | |
}); | |
// --------------------------------------------------------------------------- | |
// Top edge of element - Scroll Events | |
// --------------------------------------------------------------------------- | |
// Top edge of element reaches bottom of window | |
$(this).waypoint(function (direction) { | |
if (direction === 'down') { | |
console.log('Top of profile panel reaches the bottom of window, scrolling down'); | |
} else { | |
console.log('Top of profile panel reaches the bottom of window, scrolling up'); | |
} | |
}, { | |
offset: '100%' | |
}); | |
// Top edge of element reaches bottom of top chrome | |
$(this).waypoint(function (direction) { | |
if (direction === 'down') { | |
console.log('Top of profile panel reaches the bottom of top chrome, scrolling down'); | |
console.log('Fallback Reveal Panel Contents (for smaller screens)'); | |
} else { | |
console.log('Top of profile panel reaches the bottom of top chrome, scrolling up'); | |
} | |
}, { | |
offset: function () { | |
if (isMobileMenu === true) { | |
return ( brandBarHeight ); | |
} else { | |
return ( navHeight + brandBarHeight ); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment