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 |
checkFocusedElementExistence_(): boolean 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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
type | string | an event type |
|
listener | Function | an evnet handler |
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 removeEventListener(type: string, listener: Function) source
Remove an event listener
Params:
Name | Type | Attribute | Description |
type | string | an event type |
|
listener | Function | an evnet handler |
Private Methods
private checkFocusedElementExistence_(): boolean source
Check if the current focused element exists
Return:
boolean | whether the focused element exists |
private moveCursorTo_(rect: cursorManager$Rect) source
Move the cursor to the destination rect
Params:
Name | Type | Attribute | Description |
rect | cursorManager$Rect | the destination rect to scroll to |
|
rect.top | number | ||
rect.left | number | ||
rect.width | number | ||
rect.height | number |
private onTransitionEnd_(e: Event): * source
Event handler fro transition end
Params:
Name | Type | Attribute | Description |
e | Event | an event |
Return:
* | any value |
private onTransitionStart_(e: Event): * source
Event handler fro transition start
Params:
Name | Type | Attribute | Description |
e | Event | an event |
Return:
* | any value |
private resizeCursorTo_(rect: cursorManager$Rect) source
Move the cursor to the destination rect
Params:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
rect | cursorManager$Rect | the destination rect |
|
rect.top | number | ||
rect.left | number | ||
rect.width | number | ||
rect.height | number |
private trigger_(type: string, args: ...*) source
Trigger an event
Params:
Name | Type | Attribute | Description |
type | string | an event type |
|
args | ...* | an event type |