File tree Expand file tree Collapse file tree
src/Shared/Hooks/useStickyEvent Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- export const FALLBACK_SENTINEL_HEIGHT = '2px'
17+ export const SENTINEL_HEIGHT_BUFFER = 2
18+ export const FALLBACK_SENTINEL_HEIGHT = `${ SENTINEL_HEIGHT_BUFFER } px`
1819export const OBSERVER_THRESHOLD = 1
1920export const OBSERVER_ROOT_MARGIN = '1px'
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- import { FALLBACK_SENTINEL_HEIGHT } from './constants'
17+ import { FALLBACK_SENTINEL_HEIGHT , SENTINEL_HEIGHT_BUFFER } from './constants'
1818import { UseStickyEventReturnType } from './types'
1919
2020export const getHeightForStickyElementTopOffset = < T extends HTMLElement > ( {
@@ -30,7 +30,7 @@ export const getHeightForStickyElementTopOffset = <T extends HTMLElement>({
3030 const doesTopOffsetContainCalc = calcRegex . test ( topValue )
3131
3232 if ( doesTopOffsetContainCalc ) {
33- return topValue . replace ( calcRegex , ( match ) => `calc(${ match } + 2px )` )
33+ return topValue . replace ( calcRegex , ( match ) => `calc(${ match } + ${ SENTINEL_HEIGHT_BUFFER } px )` )
3434 }
3535
3636 return topValue . replace ( / \d + ( \. \d + ) ? / g, ( match ) => {
@@ -40,6 +40,6 @@ export const getHeightForStickyElementTopOffset = <T extends HTMLElement>({
4040 return FALLBACK_SENTINEL_HEIGHT
4141 }
4242
43- return `${ nMatch + 2 } `
43+ return `${ nMatch + SENTINEL_HEIGHT_BUFFER } `
4444 } )
4545}
You can’t perform that action at this time.
0 commit comments