Skip to content

Instantly share code, notes, and snippets.

@noahub
Created July 6, 2017 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noahub/1527450c90b9912992af5b71696a4875 to your computer and use it in GitHub Desktop.
Save noahub/1527450c90b9912992af5b71696a4875 to your computer and use it in GitHub Desktop.
Full Height Section
<script>
//Replace this ID with the full height section ID
var sectionId = "#lp-pom-block-8";
//box
var section = document.querySelector(sectionId);
var sectionChildren = section.children;
var otherContent = $('.lp-positioned-content').children();
var builderHeight = $(sectionId).height();
//find initial box height
var initHeight = builderHeight;
section.style.height = "100vh";
for(var i=0;i < sectionChildren.length; i++){
sectionChildren[i].style.height = "100vh";
}
//#lp-pom-block-8, #lp-pom-block-8 *{height:100vh;}
var moveStuff = function(type){
//find computed box height
var finalHeight = section.clientHeight;
//find difference
var diff = finalHeight - initHeight;
for (var i=0;i<otherContent.length;i++){
var content = $(otherContent[i]);
var contentTop = content.position().top;
var newTopValue = contentTop + diff;
content.css('top', newTopValue);
}
initHeight = finalHeight;
};
//Run moveStuff to adjust content on load
moveStuff("add");
var resizeTimer;
//recalculate heights on resize
window.addEventListener("resize", function(){
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
// Run code here, resizing has "stopped"
moveStuff();
}, 100);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment