test
1 month ago
analyticsApi.js
1 month ago
classnames.js
1 month ago
dateUtils.js
1 month ago
formatters.js
1 month ago
helpers.js
1 month ago
icons.js
1 month ago
index.js
1 month ago
pluginUtils.js
1 month ago
transformers.js
1 month ago
viewportBoundary.js
1 month ago
viewportBoundary.js
26 lines
| 1 | const PADDING_PX = 16; |
| 2 | let boundaryElement = null; |
| 3 | |
| 4 | export const getViewportBoundary = () => { |
| 5 | if ( typeof document === 'undefined' ) { |
| 6 | return 'clippingAncestors'; |
| 7 | } |
| 8 | if ( ! boundaryElement || ! document.body.contains( boundaryElement ) ) { |
| 9 | const el = document.createElement( 'div' ); |
| 10 | el.setAttribute( 'aria-hidden', 'true' ); |
| 11 | el.dataset.dropdownViewportBoundary = 'true'; |
| 12 | Object.assign( el.style, { |
| 13 | position: 'fixed', |
| 14 | top: `${ PADDING_PX }px`, |
| 15 | right: `${ PADDING_PX }px`, |
| 16 | bottom: `${ PADDING_PX }px`, |
| 17 | left: `${ PADDING_PX }px`, |
| 18 | pointerEvents: 'none', |
| 19 | zIndex: '-1', |
| 20 | } ); |
| 21 | document.body.appendChild( el ); |
| 22 | boundaryElement = el; |
| 23 | } |
| 24 | return boundaryElement; |
| 25 | }; |
| 26 |