0

I’d like to get the view height without using window or document.

I’d also like to get the distance between the top of an element and the top of the view height without using document at all!

I am using Angular 4 to set the height of elements based on where it is. It works right now but I’m being told that using the DOM is not very safe. I have my element hooked up using ViewChild right now. Any advice on how to accomplish this using anything other than window or document?

Preferably there is a way to do it using nativeElement

skyleguy
  • 979
  • 3
  • 19
  • 35
  • 1
    Um... what do you mean by "using the DOM is not very safe"? For example, calling `window.innerHeight` doesn't manipulate the DOM, it just tells you how tall the window viewport is. The only way around it that I could think of would be to create a wrapper element with `height: 100vh` and pull the `clientHeight` of that, but it seems like an unnecessary workaround. – jmcgriz Apr 18 '18 at 14:15
  • 1
    By manipulating anything in the front end through clientside, you are manipulating the DOM - it's not just to do with the window and document objects – Pete Apr 18 '18 at 14:17
  • https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction – Pete Apr 18 '18 at 14:26

0 Answers0