Home Reference Source Test
import CursorManager from 'spatial-navigation-cursor'
public class | source

CursorManager

Constructor Summary

Public Constructor
public

constructor(props: Object)

Member Summary

Private Members
private

cursor_: HTMLElement

private

eventListeners_: Object[]

private

focusClassName_: string

private

focused_: HTMLElement

private

freezed_: boolean

private

observer_: MutationObserver

private

root_: HTMLElement

private

viewHeight_: string

Method Summary

Public Methods
public

addEventListener(type: string, listener: Function)

Add an event listener

public

focus()

Focus on the element with the cursor

public

freeze()

Freeze the cursor

public

getCursor(): HTMLElement

Get the cursor element

public

getFocusedElement(): HTMLElement

Add an event listener

public

move()

Move the cursor

public

place()

Place the cursor

public

removeEventListener(type: string, listener: Function)

Remove an event listener

public

resize()

Resize the cursor to the dimension of the focused element

public

resume()

Resume the manager

public

start()

Start the manager

public

stop()

Stop the manager

Private Methods
private

Append the cursor to the root

private

Check if the current focused element exists

private

Stop Observering the change of focused elements

private

Hide the cursor

private

Listen to the cursor's event

private

moveCursorTo_(rect: cursorManager$Rect)

Move the cursor to the destination rect

private

Observe the change of focused elements

private

onTransitionEnd_(e: Event): *

Event handler fro transition end

private

onTransitionStart_(e: Event): *

Event handler fro transition start

private

Append the cursor to the root

private

resizeCursorTo_(rect: cursorManager$Rect)

Move the cursor to the destination rect

private

scrollIntoView_(rect: cursorManager$Rect)

Scroll into view of destination rect

private

Show the cursor

private

Style the cursor

private

trigger_(type: string, args: ...*)

Trigger an event

private

Unlisten to the cursor's event

private

Update the cursor's modifier

Public Constructors

public constructor(props: Object) source

Params:

NameTypeAttributeDescription
props Object
props.root HTMLElement

an HTML element to use as its root

props.focusClassName string

a css class name to identify the focused element

Private Members

private cursor_: HTMLElement source

private eventListeners_: Object[] source

private focusClassName_: string source

private focused_: HTMLElement source

private freezed_: boolean source

private observer_: MutationObserver source

private root_: HTMLElement source

private viewHeight_: string source

Public Methods

public addEventListener(type: string, listener: Function) source

Add an event listener

Params:

NameTypeAttributeDescription
type string

an event type

listener Function

an evnet handler

public focus() source

Focus on the element with the cursor

public freeze() source

Freeze the cursor

public getCursor(): HTMLElement source

Get the cursor element

Return:

HTMLElement

the cursor element

public getFocusedElement(): HTMLElement source

Add an event listener

Return:

HTMLElement

the focused element

public move() source

Move the cursor

public place() source

Place the cursor

public removeEventListener(type: string, listener: Function) source

Remove an event listener

Params:

NameTypeAttributeDescription
type string

an event type

listener Function

an evnet handler

public resize() source

Resize the cursor to the dimension of the focused element

public resume() source

Resume the manager

public start() source

Start the manager

public stop() source

Stop the manager

Private Methods

private appendToRoot_() source

Append the cursor to the root

private checkFocusedElementExistence_(): boolean source

Check if the current focused element exists

Return:

boolean

whether the focused element exists

private disconnectFocus_() source

Stop Observering the change of focused elements

private hideCursor_() source

Hide the cursor

private listenToCursorEvents_() source

Listen to the cursor's event

private moveCursorTo_(rect: cursorManager$Rect) source

Move the cursor to the destination rect

Params:

NameTypeAttributeDescription
rect cursorManager$Rect

the destination rect to scroll to

rect.top number
rect.left number
rect.width number
rect.height number

private observeFocus_() source

Observe the change of focused elements

private onTransitionEnd_(e: Event): * source

Event handler fro transition end

Params:

NameTypeAttributeDescription
e Event

an event

Return:

*

any value

private onTransitionStart_(e: Event): * source

Event handler fro transition start

Params:

NameTypeAttributeDescription
e Event

an event

Return:

*

any value

private removeFromRoot_() source

Append the cursor to the root

private resizeCursorTo_(rect: cursorManager$Rect) source

Move the cursor to the destination rect

Params:

NameTypeAttributeDescription
rect cursorManager$Rect

the destination rect to scroll to

rect.top number
rect.left number
rect.width number
rect.height number

private scrollIntoView_(rect: cursorManager$Rect) source

Scroll into view of destination rect

Params:

NameTypeAttributeDescription
rect cursorManager$Rect

the destination rect

rect.top number
rect.left number
rect.width number
rect.height number

private showCursor_() source

Show the cursor

private styleCursor_() source

Style the cursor

private trigger_(type: string, args: ...*) source

Trigger an event

Params:

NameTypeAttributeDescription
type string

an event type

args ...*

an event type

private unlistenToCursorEvents_() source

Unlisten to the cursor's event

private updateCursorModifier_() source

Update the cursor's modifier