Skip to main content

@pexip/hooks

Type Aliases

AutoHideUIInterfacesState

Ƭ AutoHideUIInterfacesState: "visible" | "hidden"

Variables

UI_INACTIVITY_TIMEOUT

Const UI_INACTIVITY_TIMEOUT: 5000


autoHideUIInterfacesStateSignal

Const autoHideUIInterfacesStateSignal: Signal<AutoHideUIInterfacesState>


fullscreenSignal

Const fullscreenSignal: Signal<boolean>

Functions

isFullscreen

isFullscreen(fullscreenElement): boolean

a boolean that indicates whether the document is in full-screen mode.

Parameters

NameType
fullscreenElementnull | Element

Returns

boolean


useAnimationFrame

useAnimationFrame(callback, shouldStop?): void

Parameters

NameTypeDefault value
callbackFrameRequestCallbackundefined
shouldStopbooleanfalse

Returns

void


useAutoHideUIInterfaces

useAutoHideUIInterfaces(isStreamReady, isDisabledByConfig, shouldDisplay?): Object

Hook to signal display state (show/hide) based on UI inactivity timeout

Parameters

NameTypeDescription
isStreamReadybooleanonly apply autoHide if we've got a ready stream
isDisabledByConfigbooleanif true then auto hiding is disabled, UI controls will not be hidden
shouldDisplay?(shouldDisplay: boolean) => voidcallback to signal when to hide and when to show

Returns

Object

control to enable/disable auto hide functionality

NameType
enableAutoHideDispatch<SetStateAction<boolean>>
enableAutoHideConstraintBased(constraint: boolean) => void

useCountDown

useCountDown(state, onCountDownFinished?): Object

Parameters

NameType
stateCountDownState
onCountDownFinished?() => void

Returns

Object

NameType
cleanup() => void
currentCountnumber
startCountDown() => void

useEnter

useEnter<T>(fn): Object

Type parameters

NameType
Textends Element

Parameters

NameType
fn(e: KeyboardEvent<T>) => void

Returns

Object

NameType
onKeyDownundefined | KeyboardEventHandler<FocusableElement>

useFullscreenApi

useFullscreenApi(): FullscreenApi

returns a Browser API agnostic access to the Fullscreen API.

See

https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API/Guide#prefixing

Returns

FullscreenApi


useHotKey

useHotKey(«destructured»): void

Parameters

NameType
«destructured»Object
› disallowedKeys?DisallowedKeys
› handler() => void
› isDisabled?boolean
› keystring

Returns

void


useInterval

useInterval(callback, delay?): void

Parameters

NameType
callbackCallbackFn
delay?number

Returns

void


useIsInWindowBottomHalf

useIsInWindowBottomHalf(): Object

Returns

Object

NameType
isInBottomHalfboolean
update(el: HTMLElement) => void

useIsInWindowRightHalf

useIsInWindowRightHalf(): Object

Returns

Object

NameType
isInRightHalfboolean
update(el: HTMLElement) => void

useIsMounted

useIsMounted(): () => boolean

From https://usehooks-ts.com/react-hook/use-is-mounted

Deprecated

React recommends to use cancelable promises instead https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html

Returns

fn

▸ (): boolean

Returns

boolean


useMatchMedia

useMatchMedia(mediaQuery): boolean

Parameters

NameType
mediaQuerystring

Returns

boolean


useOnClickOutside

useOnClickOutside(fn): RefCallback<HTMLElement>

Hook that only runs callback on click events outside of the referenced element

Parameters

NameTypeDescription
fn() => voidthe function to be called on click outside

Returns

RefCallback<HTMLElement>

a ref to the element where we are listening for clicks


usePrevious

usePrevious<T>(value): undefined | T

Type parameters

Name
T

Parameters

NameType
valueT

Returns

undefined | T


useSizeObserver

useSizeObserver(element): Object

Parameters

NameType
elementHTMLElement

Returns

Object

NameType
heightnumber
widthnumber

useToggleFullscreen

useToggleFullscreen(): () => void

useCallback to toggle browser's fullscreen.

Returns

fn

▸ (): void

Returns

void


useWideContainerObserver

useWideContainerObserver(): Object

Returns

Object

NameType
containerRefRefObject<HTMLDivElement>
isContainerWideboolean