I have an html element whose height is set to 100vh and value of overflow is set to auto. So user can scroll the element to view it. What I want is to calculate actual height of the element. I am using offsetHeight property to calculate height. But is is giving me only 100vh height. But what I want is the height which will be given by offsetHeight when height of element is set to auto. How to calculate it when height of the element is set to 100vh.
1 Answer
I am new in this business but I use this code the calculate height of the div (whatever div that I choose It doesn't matter).
let height = document.querySelector("div").offsetHeight; if ( document.body.scrollTop > height || document.documentElement.scrollTop > height ) { //code } else { //code }
window.innerHeight, btw 100vh won't be correct in i(phone|pad), so is better to set a var and use cssvar(--vh)instead, example: repl.it/@lcherone/iPad-100vh-fix#index.html