Function
inview
(viewtop, viewbottom, el)
Source from the content-addressed store, hash-verified
| 1133 | } |
| 1134 | |
| 1135 | function inview(viewtop, viewbottom, el) { |
| 1136 | const rect = el.getBoundingClientRect(); |
| 1137 | const elemmiddle = rect.top + window.scrollY + rect.height / 2; |
| 1138 | |
| 1139 | // we consider the element to be in view when its middle is |
| 1140 | // within the viewport |
| 1141 | return viewtop < elemmiddle && viewbottom > elemmiddle; |
| 1142 | } |
| 1143 | |
| 1144 | function drawvisible() { |
| 1145 | let viewtop = window.scrollY; |
Tested by
no test coverage detected