Skip to content

Class: CrowsNest

CrowsNest is a class which provides the "safe" full screen area that can be used without being cut off by the shape of the display or browser UI elements. including whether or not a virtual keyboard is open.

Constructors

Constructor

ts
new CrowsNest(onDebug?: (...args: []) => void): CrowsNest;

Creates a new CrowsNest instance

Parameters

ParameterTypeDescription
onDebug?(...args: []) => voidA callback function which is called when a debug message is emitted

Returns

CrowsNest

Accessors

keyboard

Get Signature

ts
get keyboard(): KeyboardState;

Determines if the virtual keyboard is open or closed

Returns

KeyboardState


observable

Get Signature

ts
get observable(): Surface;

The area which is safe to put content into without risking it being cut off by the shape of a non‑rectangular display or the virtual keyboard

Returns

Surface


apis

Get Signature

ts
get static apis(): {
  Document: boolean;
  ResizeObserver: boolean;
  Screen: boolean;
  VirtualKeyboard: boolean;
  VisualViewport: boolean;
  Window: boolean;
  WindowControlsOverlay: boolean;
};

Returns a boolean indicating if an API which is used by CrowsNest is available in the current environment.

Returns
ts
{
  Document: boolean;
  ResizeObserver: boolean;
  Screen: boolean;
  VirtualKeyboard: boolean;
  VisualViewport: boolean;
  Window: boolean;
  WindowControlsOverlay: boolean;
}
NameTypeDescription
DocumentbooleanIf the Document API is available in the current environment
ResizeObserverbooleanIf the ResizeObserver API is available in the current environment
ScreenbooleanIf the Screen API is available in the current environment
VirtualKeyboardbooleanIf the VirtualKeyboard API is available in the current environment
VisualViewportbooleanIf the VisualViewport API is available in the current environment
WindowbooleanIf the Window API is available in the current environment
WindowControlsOverlaybooleanIf the WindowControlsOverlay API is available in the current environment

Methods

bindHtmlElement()

ts
bindHtmlElement(elem: HTMLElement): void;

Bind Crows Nest to an HTML element. This will make the element resize and move with the observable safe area.

Parameters

ParameterTypeDescription
elemHTMLElementThe HTML element to bind to the observable safe area

Returns

void


bindVueRef()

ts
bindVueRef(ref: Ref<Surface>): void;

Bind Crows Nest to a Vue ref. This will update the ref with the observable safe area.

Parameters

ParameterTypeDescription
refRef<Surface>The Vue ref to bind to the observable safe area

Returns

void


destroy()

ts
destroy(): void;

Removes all elements and event listeners created by CrowsNest

Returns

void


off()

ts
off<K>(event: K, callback?: CrowsNestEvents[K]): this;

Removes the specified listener from the listener array for the event named eventName.

off() will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times to the listener array for the specified eventName, then off() must be called multiple times to remove each instance.

Once an event is emitted, all listeners attached to it at the time of emitting are called in order. This implies that any off() calls after emitting and before the last listener finishes execution will not remove them fromemit() in progress. Subsequent events behave as expected.

Because listeners are managed using an internal array, calling this will change the position indices of any listener registered after the listener being removed. This will not impact the order in which listeners are called.

When a single function has been added as a handler multiple times for a single event, off() will remove the most recently added instance.

Returns a reference to the CrowsNest, so that calls can be chained.

Type Parameters

Type Parameter
K extends string | number

Parameters

ParameterType
eventK
callback?CrowsNestEvents[K]

Returns

this


on()

ts
on<K>(
   event: K,
   callback: CrowsNestEvents[K],
   ctx?: any): this;

Adds the listener function to the end of the listeners array for the event named event. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times.

Returns a reference to the CrowsNest, so that calls can be chained.

Event listeners are invoked in the order they are added.

Type Parameters

Type Parameter
K extends keyof CrowsNestEvents

Parameters

ParameterTypeDescription
eventKThe name of the event.
callbackCrowsNestEvents[K]The callback function
ctx?any-

Returns

this


once()

ts
once<K>(
   event: K,
   callback: CrowsNestEvents[K],
   ctx?: any): this;

Adds a one-time listener function for the event named event. The next time event is triggered, this listener is removed and then invoked.

Returns a reference to the CrowsNest, so that calls can be chained.

Event listeners are invoked in the order they are added.

Type Parameters

Type Parameter
K extends keyof CrowsNestEvents

Parameters

ParameterTypeDescription
eventKThe name of the event.
callbackCrowsNestEvents[K]The callback function
ctx?any-

Returns

this


unbindHtmlElement()

ts
unbindHtmlElement(elem: HTMLElement): void;

Unbind Crows Nest from an HTML element. This will stop the element from resizing and moving with the observable safe area.

Parameters

ParameterTypeDescription
elemHTMLElementThe HTML element to unbind from the observable safe area

Returns

void


unbindVueRef()

ts
unbindVueRef(ref: Ref<Surface>): void;

Unbind Crows Nest from a Vue ref. This will stop the ref from updating with the observable safe area.

Parameters

ParameterTypeDescription
refRef<Surface>The Vue ref to unbind from the observable safe area

Returns

void