Created
July 6, 2017 19:38
-
-
Save noahub/1527450c90b9912992af5b71696a4875 to your computer and use it in GitHub Desktop.
Full Height Section
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
<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