무한 스크롤을 구현하기 위해 scroll event에 대해 알아보던 중 브라우저 element의 height에 대해 정리해보기로 했다. 스크롤이 화면 끝에 닿았을 때 새로운 컨텐츠를 보여주어야 하는 무한 스크롤 구현이 목적이기 때문에 width는 제외하고 height 위주로 정리하였다.
These properties are like clientHeight, but they also include the scrolled out (hidden) parts.
Properties scrollTop are the height of the hidden, scrolled out part of the element.
These two properties are the simplest ones. They provide the “outer” width/height of the element. Or, in other words, its full size including borders.
The offsetParent is the nearest ancestor that the browser uses for calculating coordinates during rendering.
That’s the nearest ancestor that is one of the following:
1. CSS-positioned (position is absolute, relative, fixed or sticky), or
2.<td>
,<th>
, or<table>
, or
3.<body>
.
Properties offsetLeft/offsetTop provide x/y coordinates relative to offsetParent upper-left corner.
<table>
, <td>
, <th>
<body>
These properties provide the size of the area inside the element borders.
They include the content width together with paddings, but without the scrollbar.
Inside the element we have the borders.
To measure them, there are properties clientTop and clientLeft.