( scrollThreshold: number | string, inverse: boolean )
| 20 | * For inverse mode the margin is applied to the top instead of the bottom. |
| 21 | */ |
| 22 | export function buildRootMargin( |
| 23 | scrollThreshold: number | string, |
| 24 | inverse: boolean |
| 25 | ): string { |
| 26 | const threshold = parseThreshold(scrollThreshold); |
| 27 | |
| 28 | let margin: string; |
| 29 | if (threshold.unit === ThresholdUnits.Pixel) { |
| 30 | margin = `${threshold.value}px`; |
| 31 | } else { |
| 32 | // threshold.value is already in percent (e.g. 80 for 0.8 input) |
| 33 | const remaining = 100 - threshold.value; |
| 34 | margin = `${remaining}%`; |
| 35 | } |
| 36 | |
| 37 | return inverse ? `${margin} 0px 0px 0px` : `0px 0px ${margin} 0px`; |
| 38 | } |
no test coverage detected
searching dependent graphs…