Class: Button

OpenSeadragon.Button

Manages events, hover states for individual buttons, tool-tips, as well as fading the buttons out when the user has not interacted with them for a specified period.

Constructor

new Button(options)

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
element Element <optional>
null Element to use as the button. If not specified, an HTML <button> element is created.
tooltip String <optional>
null Provides context help for the button when the user hovers over it.
srcRest String <optional>
null URL of image to use in 'rest' state.
srcGroup String <optional>
null URL of image to use in 'up' state.
srcHover String <optional>
null URL of image to use in 'hover' state.
srcDown String <optional>
null URL of image to use in 'down' state.
fadeDelay Number <optional>
0 How long to wait before fading.
fadeLength Number <optional>
2000 How long should it take to fade the button.
onPress OpenSeadragon.EventHandler <optional>
null Event handler callback for OpenSeadragon.Button.event:press.
onRelease OpenSeadragon.EventHandler <optional>
null Event handler callback for OpenSeadragon.Button.event:release.
onClick OpenSeadragon.EventHandler <optional>
null Event handler callback for OpenSeadragon.Button.event:click.
onEnter OpenSeadragon.EventHandler <optional>
null Event handler callback for OpenSeadragon.Button.event:enter.
onExit OpenSeadragon.EventHandler <optional>
null Event handler callback for OpenSeadragon.Button.event:exit.
onFocus OpenSeadragon.EventHandler <optional>
null Event handler callback for OpenSeadragon.Button.event:focus.
onBlur OpenSeadragon.EventHandler <optional>
null Event handler callback for OpenSeadragon.Button.event:blur.
Source:

Extends

Members

currentState :OpenSeadragon.ButtonState

The button's current state.
Type:
Source:

element :Element

The button element.
Type:
  • Element
Source:

fadeDelay :Number

How long to wait before fading.
Type:
  • Number
Source:

fadeLength :Number

How long should it take to fade the button.
Type:
  • Number
Source:

tracker :OpenSeadragon.MouseTracker

Tracks mouse/touch/key events on the button.
Type:
Source:

Methods

addHandler(eventName, handler, userDataopt)

Add an event handler for a given event.
Parameters:
Name Type Attributes Default Description
eventName String Name of event to register.
handler OpenSeadragon.EventHandler Function to call when event is triggered.
userData Object <optional>
null Arbitrary object to be passed unchanged to the handler.
Inherited From:
Source:

addOnceHandler(eventName, handler, userDataopt, timesopt)

Add an event handler to be triggered only once (or a given number of times) for a given event.
Parameters:
Name Type Attributes Default Description
eventName String Name of event to register.
handler OpenSeadragon.EventHandler Function to call when event is triggered.
userData Object <optional>
null Arbitrary object to be passed unchanged to the handler.
times Number <optional>
1 The number of times to handle the event before removing it.
Inherited From:
Source:

disable()

Source:

enable()

Source:

getHandler(eventName)

Get a function which iterates the list of all handlers registered for a given event, calling the handler for each.
Parameters:
Name Type Description
eventName String Name of event to get handlers for.
Inherited From:
Source:

notifyGroupEnter()

TODO: Determine what this function is intended to do and if it's actually useful as an API point.
Source:

notifyGroupExit()

TODO: Determine what this function is intended to do and if it's actually useful as an API point.
Source:

raiseEvent(eventName, eventArgs)

Trigger an event, optionally passing additional information.
Parameters:
Name Type Description
eventName String Name of event to register.
eventArgs Object Event-specific data.
Inherited From:
Source:

removeAllHandlers(eventName)

Remove all event handlers for a given event type. If no type is given all event handlers for every event type are removed.
Parameters:
Name Type Description
eventName String Name of event for which all handlers are to be removed.
Inherited From:
Source:

removeHandler(eventName, handler)

Remove a specific event handler for a given event.
Parameters:
Name Type Description
eventName String Name of event for which the handler is to be removed.
handler OpenSeadragon.EventHandler Function to be removed.
Inherited From:
Source:

Events

blur

Raised when the Button element loses focus.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Button A reference to the Button which raised the event.
originalEvent Object The original DOM event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

click

Raised when a mouse button is pressed and released or touch is initiated and ended in the Button element within the time and distance threshold.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Button A reference to the Button which raised the event.
originalEvent Object The original DOM event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

enter

Raised when the cursor enters the Button element.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Button A reference to the Button which raised the event.
originalEvent Object The original DOM event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

exit

Raised when the cursor leaves the Button element.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Button A reference to the Button which raised the event.
originalEvent Object The original DOM event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

focus

Raised when the Button element receives focus.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Button A reference to the Button which raised the event.
originalEvent Object The original DOM event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

press

Raised when a mouse button is pressed or touch occurs in the Button element.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Button A reference to the Button which raised the event.
originalEvent Object The original DOM event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

release

Raised when the mouse button is released or touch ends in the Button element.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Button A reference to the Button which raised the event.
originalEvent Object The original DOM event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source: