Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 00031f9

Browse files
committed
bug fix for flush height use document offset instead
1 parent f335ffe commit 00031f9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/scripts/directives/flush-height.directive.coffee

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
'use strict';
1+
'use strict'
2+
3+
getOffsetTop = (elem) ->
4+
offsetTop = elem.offsetTop
5+
6+
while elem = elem.offsetParent
7+
unless isNaN(elem.offsetTop)
8+
offsetTop += elem.offsetTop
9+
10+
offsetTop
211

312
dir = ($window) ->
413
viewPortHeight = 0
@@ -12,7 +21,7 @@ dir = ($window) ->
1221
setViewPortHeight()
1322

1423
flushHeight = ($element) ->
15-
top = $element[0]?.getBoundingClientRect()?.top
24+
top = getOffsetTop $element[0]
1625
heightDiff = viewPortHeight - top
1726

1827
$element.height heightDiff

0 commit comments

Comments
 (0)