Skip to content

Instantly share code, notes, and snippets.

@morsecodemedia
Created November 3, 2020 20:22
Show Gist options
  • Save morsecodemedia/f54327c00b694fbf54a921936e7312df to your computer and use it in GitHub Desktop.
Save morsecodemedia/f54327c00b694fbf54a921936e7312df to your computer and use it in GitHub Desktop.
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