Helper to extract the offset of a DOM Node in a certain direction.
(orientation: 'horizontal' | 'vertical', direction: 'start' | 'end', node: Node)
| 61 | |
| 62 | /** Helper to extract the offset of a DOM Node in a certain direction. */ |
| 63 | function getOffset(orientation: 'horizontal' | 'vertical', direction: 'start' | 'end', node: Node) { |
| 64 | const el = node as Element; |
| 65 | if (!el.getBoundingClientRect) { |
| 66 | return 0; |
| 67 | } |
| 68 | const rect = el.getBoundingClientRect(); |
| 69 | |
| 70 | if (orientation === 'horizontal') { |
| 71 | return direction === 'start' ? rect.left : rect.right; |
| 72 | } |
| 73 | |
| 74 | return direction === 'start' ? rect.top : rect.bottom; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling |
no test coverage detected