Closed karimhossenbux closed 7 years ago
Thanks for opening the issue.
Since, as you pointed out, document.body.clientWidth
doesn't work as expected when the doctype is declared, a simpler solution would be to directly replace document.body.clientHeight
in favor of window.innerHeight
(document.documentElement.clientHeight
doesn't work when the doctype is not declared):
-const windowWidth = document.body.clientWidth || window.innerWidth
-const windowHeight = document.body.clientHeight || window.innerHeight
+const windowWidth = window.innerWidth
+const windowHeight = window.innerHeight
This way, it would work with or without the doctype declared.
What do you think?
Yes sure, if that works in both case, that's better!
Found a bug when having doctype declared.
When the doctype is set,
document.body.clientHeight
returns a bigger value than expected, the same height as thebody
instead of the height of the actual viewport.Maybe the solution here is to replace
document.body.clientHeight
withdocument.documentElement.clientHeight
?