Class: World

OpenSeadragon.World

Keeps track of all of the tiled images in the scene.

Constructor

new World(options)

Parameters:
Name Type Description
options Object World options.
Properties
Name Type Description
viewer OpenSeadragon.Viewer The Viewer that owns this World.
Source:

Extends

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:

addItem(item)

Add the specified item.
Parameters:
Name Type Attributes Description
item OpenSeadragon.TiledImage The item to add.
options.index Number <optional>
Index for the item. If not specified, goes at the top.
Source:
Fires:

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:

arrange(options)

Arranges all of the TiledImages with the specified settings.
Parameters:
Name Type Description
options Object Specifies how to arrange.
Properties
Name Type Attributes Default Description
immediately Boolean <optional>
false Whether to animate to the new arrangement.
layout String <optional>
See collectionLayout in OpenSeadragon.Options.
rows Number <optional>
See collectionRows in OpenSeadragon.Options.
columns Number <optional>
See collectionColumns in OpenSeadragon.Options.
tileSize Number <optional>
See collectionTileSize in OpenSeadragon.Options.
tileMargin Number <optional>
See collectionTileMargin in OpenSeadragon.Options.
Source:
Fires:

draw()

Draws all items.
Source:

getContentFactor() → {Number}

To facilitate zoom constraints, we keep track of the pixel density of the densest item in the World (i.e. the item whose content size to viewport size ratio is the highest) and save it as this "content factor".
Source:
Returns:
the number of content units per viewport unit.
Type
Number

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:

getHomeBounds() → {OpenSeadragon.Rect}

Source:
Returns:
The smallest rectangle that encloses all items, in viewport coordinates.
Type
OpenSeadragon.Rect

getIndexOfItem(item) → {Number}

Get the index of the given item or -1 if not present.
Parameters:
Name Type Description
item OpenSeadragon.TiledImage The item.
Source:
Returns:
The index of the item or -1 if not present.
Type
Number

getItemAt(index) → {OpenSeadragon.TiledImage}

Get the item at the specified index.
Parameters:
Name Type Description
index Number The item's index.
Source:
Returns:
The item at the specified index.
Type
OpenSeadragon.TiledImage

getItemCount() → {Number}

Source:
Returns:
The number of items used.
Type
Number

needsDraw() → {Boolean}

Source:
Returns:
true if any items need updating.
Type
Boolean

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:

removeAll()

Remove all items.
Source:
Fires:

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:

removeItem(item)

Remove an item.
Parameters:
Name Type Description
item OpenSeadragon.TiledImage The item to remove.
Source:
Fires:

resetItems()

Clears all tiles and triggers updates for all items.
Source:

setAutoRefigureSizes(valueopt)

As a performance optimization, setting this flag to false allows the bounds-change event handler on tiledImages to skip calculations on the world bounds. If a lot of images are going to be positioned in rapid succession, this is a good idea. When finished, setAutoRefigureSizes should be called with true or the system may behave oddly.
Parameters:
Name Type Attributes Description
value Boolean <optional>
The value to which to set the flag.
Source:

setItemIndex(item, index)

Change the index of a item so that it appears over or under others.
Parameters:
Name Type Description
item OpenSeadragon.TiledImage The item to move.
index Number The new index.
Source:
Fires:

update()

Updates (i.e. animates bounds of) all items.
Source:

Events

add-item

Raised when an item is added to the World.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.Viewer A reference to the World which raised the event.
item OpenSeadragon.TiledImage The item that has been added.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

item-index-change

Raised when the order of the indexes has been changed.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.World A reference to the World which raised the event.
item OpenSeadragon.TiledImage The item whose index has been changed
previousIndex Number The previous index of the item
newIndex Number The new index of the item
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

metrics-change

Raised when the home bounds or content factor change.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.World A reference to the World which raised the event.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source:

remove-item

Raised when an item is removed.
Type:
  • object
Properties:
Name Type Attributes Description
eventSource OpenSeadragon.World A reference to the World which raised the event.
item OpenSeadragon.TiledImage The item's underlying item.
userData Object <nullable>
Arbitrary subscriber-defined object.
Source: