compute height in Javascript to avoid hovered image jumping