I am using Marko and am needing to access the window and viewport height. I need the height of a specific div, and the height of the viewport. This is typically achieved by something similar to this
var viewportHeight = window.innerHeight
var elementHeight = document.getElementById("#myDiv").clientHeight
Can I access window
and document
within a class like so?
class {
onCreate(){
var windowHeight = window.innerHeight
var elementHeight = document.getElementById("#myDiv").clientHeight
this.state = { winHeight: winHeight, elemHeight: elementHeight }
}
}
#myDiv
p -- ${state.winHeight}
p -- ${state.elemHeight}
I am getting errors:
ReferenceError: document is not defined
ReferenceError: window is not defined
What is the best way to access those values within my markup?