Created
November 3, 2020 20:22
-
-
Save morsecodemedia/f54327c00b694fbf54a921936e7312df 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
import utils from './utils' | |
class VH { | |
constructor () { | |
var debounceResize = utils.debounce(this, this.hasResized, 100) | |
window.addEventListener('resize', debounceResize) | |
this.hasResized() | |
} | |
hasResized () { | |
let vh = window.innerHeight * 0.01 | |
document.documentElement.style.setProperty('--vh', `${vh}px`) | |
} | |
} | |
export default new VH() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment