0

I am trying to get offset height of div to do some calculations and I noticed that it always returns the same height even on smaller screens and mobiles when the div height is different, so I don't get it why doesn't it return the correct height on mobile? any help please?

      useEffect(() => {
        const videoParent: any = playerWrapperReference.current?.parentNode;
        videoParentNode.current = videoParent;
        videoOffsetHeight.current =
        playerWrapperReference.current != null 
          ? playerWrapperReference.current.offsetHeight
          : 0;
      }, []);
NQQ
  • 51
  • 1
  • 5
  • 1
    Can you share your current code so that we can see your problem? – Mihail Minkov May 08 '21 at 05:32
  • thank you for your reply , my code is huge so i added the relative part , im getting the height from a ref on component did mount and storing it in another ref as I need to use it later inside event listener callback, but the offset height is always returned as if its on desktop even if i switch to mobile , any ideas? – NQQ May 08 '21 at 06:14
  • When you say you 'switch to mobile' is that using a real mobile device or some browser emulator? If in browser, what browser? – A Haworth May 08 '21 at 10:20
  • Your sample doesn't allow us test it and see for ourselves the problem. – vanowm May 08 '21 at 13:49
  • @nuraqasrawi At least add a basic reproduceable example, or upload it to jsbin or something similar. – Mihail Minkov May 10 '21 at 16:47

0 Answers0