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