Last active
November 23, 2020 03:18
-
-
Save Phongtlam/b8bd55fdcd1a0fa77f52210e3e149a76 to your computer and use it in GitHub Desktop.
adjustPaddings
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
const adjustPaddings = isScrollDown => { | |
const container = document.querySelector(".cat-list"); | |
const currentPaddingTop = getNumFromStyle(container.style.paddingTop); | |
const currentPaddingBottom = getNumFromStyle(container.style.paddingBottom); | |
const remPaddingsVal = 170 * (listSize / 2); | |
if (isScrollDown) { | |
container.style.paddingTop = currentPaddingTop + remPaddingsVal + "px"; | |
container.style.paddingBottom = currentPaddingBottom === 0 ? "0px" : currentPaddingBottom - remPaddingsVal + "px"; | |
} else { | |
container.style.paddingBottom = currentPaddingBottom + remPaddingsVal + "px"; | |
container.style.paddingTop = currentPaddingTop === 0 ? "0px" : currentPaddingTop - remPaddingsVal + "px"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment