My bad, i forgot to add that.
I am now calculating the amount of spacing using the height of the elements, thanks for pointing that out.
const panelHeight = panel.offsetHeight;
So, i am close to getting the desired behaviour i want (the content section is moving on top the hero ). One more thing, some contents are hidden and not displayed when i scroll. i have 3 sections inside
<div className="panel content"></div>
but i only get to see one when i scroll. how can i fix this? Thanks