@acusti/use-is-out-of-bounds
Version:
React hook that detects if an element is outside of its parent’s bounds on any of its sides (like collision detection)
13 lines (12 loc) • 339 B
TypeScript
type MaybeHTMLElement = HTMLElement | null;
type OutOfBounds = {
bottom: boolean;
hasLayout: boolean;
left: boolean;
maxHeight: null | number;
maxWidth: null | number;
right: boolean;
top: boolean;
};
declare const useIsOutOfBounds: (element?: MaybeHTMLElement) => OutOfBounds;
export default useIsOutOfBounds;