Skip to content

Commit

Permalink
Adjust hero sticky offset on smaller screens.
Browse files Browse the repository at this point in the history
This is a trick to account for the variable height of the toolbar on mobile,
which causes the 'stuck' class to be attached on document load (before
scrolling begins).
  • Loading branch information
boonebgorges committed Oct 26, 2020
1 parent e0996da commit 8296401
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion assets/js/cacap.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ window.wp = window.wp || {};
$('#cacap-header').height( hero_height - 85 );
} else {
var window_height = "innerHeight" in window ? window.innerHeight : document.documentElement.offsetHeight;
var window_width = "innerWidth" in window ? window.innerWidth : document.documentElement.offsetWidth;

var stickyOffset = window_width > 600 ? 0 : -5;

if ( window_height < $(document).height() - 200 ) {
$('.cacap-hero-row').waypoint('sticky', {
offset: 0,
offset: stickyOffset,
wrapper: '<div class="cacap-hero-row-sticky" />'
} );
}
Expand Down

0 comments on commit 8296401

Please sign in to comment.