What is the best practice of getting element's height in controller

Hello everyone

In this case, I have a element which is position:fixed and its top(css) depends on another element’s height, what is the best practice of getting that element’s height in controller?

Or how can we do it dynamically?