Jet Link Simulations

Jet Link Simulations

  • Docs
  • API Reference
  • Help

BrowserEvent

Convenience class to detect browser events on the browser window object.

This class has methods that allow you to pass a callback function to run for specific events. These events include load, resize, wheel, deviceorientation, devicemotion, unload.

JLS.events.BrowserEvent

new BrowserEvent()

    let browserEvent = new BrowserEvent()

    // Detecting a browser event
    browserEvent
        .onLoad(() => { 
            // do something
        })
        .onResize(() => {
            // do something
        })


    // Choosing not to listen to auto-registered events
    browserEvent.unsubscribe('devicemotion')

Members

screen

The browser window object.

registeredEvents

An array list of the registered events.

callbacks

A object containing all the registered callbacks. The object property namesare the event types.

Callbacks

onLoad(cb)

A resource and its dependent resources have finished loading.

NameTypeDescription
cbfunctionA function that is passed to run when the event is triggered.

onResize(cb)

The document view has been resized.

NameTypeDescription
cbfunctionA function that is passed to run when the event is triggered.

onWheel(cb)

A wheel button of a pointing device is rotated in any direction.

NameTypeDescription
cbfunctionA function that is passed to run when the event is triggered.

onDeviceOrientation(cb)

The orientationchange event is fired when the orientation of the device has changed.

NameTypeDescription
cbfunctionA function that is passed to run when the event is triggered.

onDeviceMotion(cb)

The devicemotion event is fired at a regular interval and indicates the amount of physical force of acceleration the device is receiving at that time. It also provides information about the rate of rotation, if available.

NameTypeDescription
cbfunctionA function that is passed to run when the event is triggered.

onUnload(cb)

The document or a dependent resource is being unloaded.

NameTypeDescription
cbfunctionA function that is passed to run when the event is triggered.

Methods

unsubscribe(event)

Detaches keydown and keyup listeners to the key and stops listening for events. Returns true if successful.

NameTypeDescription
eventstringThe event to unsubscribe and stop listening for.
Options: load, resize, wheel, deviceorientation, devicemotion, unload.

init()

Automatically called on object contruction, this method intializes the BrowserEvent by setting the window screen.

  • new BrowserEvent()
  • Members
    • screen
    • registeredEvents
  • callbacks
  • Callbacks
    • onLoad(cb)
    • onResize(cb)
    • onWheel(cb)
    • onDeviceOrientation(cb)
    • onDeviceMotion(cb)
    • onUnload(cb)
  • Methods
    • unsubscribe(event)
    • init()
Jet Link Simulations
Docs
Getting StartedGuidesAPI Reference
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Copyright © 2020 Name or Your Company Name