Fix useHasWrapped hook
This commit is contained in:
parent
ac09a508f1
commit
2bf34fbf1e
1 changed files with 5 additions and 1 deletions
|
@ -5,6 +5,10 @@ import type { Ref } from 'react';
|
|||
import { useEffect, useState } from 'react';
|
||||
import { first, last, noop } from 'lodash';
|
||||
|
||||
function getBottom(element: Readonly<Element>): number {
|
||||
return element.getBoundingClientRect().bottom;
|
||||
}
|
||||
|
||||
function getTop(element: Readonly<Element>): number {
|
||||
return element.getBoundingClientRect().top;
|
||||
}
|
||||
|
@ -22,7 +26,7 @@ function isWrapped(element: Readonly<null | HTMLElement>): boolean {
|
|||
firstChild &&
|
||||
lastChild &&
|
||||
firstChild !== lastChild &&
|
||||
getTop(firstChild) !== getTop(lastChild)
|
||||
getBottom(firstChild) <= getTop(lastChild)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue