Item
Defined in: core/items/item.ts:84
An Item is rendered from a #core/Source Source and represents an
object that is used as an item on the stage. Multiple items may be linked to
a single source and any changes made to the source would affect all linked
items.
Implements: #core/IItemLayout Core/IItemLayout
Basic Usage
Section titled “Basic Usage”var xjs = require('xjs');var Scene = xjs.Scene.getById(1);
Scene.getItems().then(function(items) { if (items.length === 0) return;
// There's a valid item, let's use that var item = items[items.length - 1]; return item.setKeepAspectRatio(true);}).then(function(item) { // Do something else here});All methods marked as Chainable resolve with the original Item instance.
This allows you to perform sequential operations correctly:
var xjs = require('xjs');var Source = xjs.Source;
// an item that sets its own properties on loadxjs.ready() .then(Source.getCurrentSource) .then(function(source) { return source.getItemList() }).then(function(items) { return items[0].setEnhancedResizeEnabled(true) }).then(function(items) { return items[0].setPositionLocked(true) }).then(function(items) { //set more properties here })Extends
Section titled “Extends”Extended by
Section titled “Extended by”AudioItemCameraItemFlashItemGameItemGroupItemHtmlItemImageItemMediaItemReplayItemSceneItemScreenItemVideoPlaylistItem
Implements
Section titled “Implements”IItemLayoutISource
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Item(
props?):Item
Defined in: core/items/item.ts:88
Parameters
Section titled “Parameters”props?
Section titled “props?”Returns
Section titled “Returns”Item
Overrides
Section titled “Overrides”Properties
Section titled “Properties”bringForward
Section titled “bringForward”bringForward: () =>
Promise<Item>
Defined in: core/items/item.ts:617
See: #core/IItemLayout#bringForward bringForward
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.bringForward
bringToFront
Section titled “bringToFront”bringToFront: () =>
Promise<Item>
Defined in: core/items/item.ts:622
See: #core/IItemLayout#bringToFront bringToFront
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.bringToFront
getCanvasRotate
Section titled “getCanvasRotate”getCanvasRotate: () =>
Promise<number>
Defined in: core/items/item.ts:642
See: #core/IItemLayout#getCanvasRotate getCanvasRotate
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IItemLayout.getCanvasRotate
getCropping
Section titled “getCropping”getCropping: () =>
Promise<Object>
Defined in: core/items/item.ts:647
See: #core/IItemLayout#getCropping getCropping
Returns
Section titled “Returns”Promise<Object>
Implementation of
Section titled “Implementation of”IItemLayout.getCropping
getCustomName
Section titled “getCustomName”getCustomName: () =>
Promise<string>
Defined in: core/items/item.ts:758
See: #core/Source#getCustomName getCustomName
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”ISource.getCustomName
Overrides
Section titled “Overrides”getEnhancedRotate
Section titled “getEnhancedRotate”getEnhancedRotate: () =>
Promise<number>
Defined in: core/items/item.ts:652
See: #core/IItemLayout#getEnhancedRotate getEnhancedRotate
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IItemLayout.getEnhancedRotate
getId: () =>
Promise<string>
Defined in: core/items/item.ts:267
return: Promise
Get the ID of the Item
item.getId().then(function(id) { // The rest of your code here});Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”ISource.getId
Overrides
Section titled “Overrides”getItemList
Section titled “getItemList”getItemList: () =>
Promise<Item[]>
Defined in: core/items/item.ts:513
See: #core/Source#getItemList getItemList
Returns
Section titled “Returns”Promise<Item[]>
Implementation of
Section titled “Implementation of”ISource.getItemList
Overrides
Section titled “Overrides”getKeepLoaded
Section titled “getKeepLoaded”getKeepLoaded: () =>
Promise<boolean>
Defined in: core/items/item.ts:773
See: #core/Source#getKeepLoaded getKeepLoaded
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”ISource.getKeepLoaded
Overrides
Section titled “Overrides”getName
Section titled “getName”getName: () =>
Promise<string>
Defined in: core/items/item.ts:748
See: #core/Source#getName getName
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”ISource.getName
Overrides
Section titled “Overrides”getPosition
Section titled “getPosition”getPosition: () =>
Promise<Rectangle>
Defined in: core/items/item.ts:657
See: #core/IItemLayout#getPosition getPosition
Returns
Section titled “Returns”Promise<Rectangle>
Implementation of
Section titled “Implementation of”IItemLayout.getPosition
getRotateX
Section titled “getRotateX”getRotateX: () =>
Promise<number>
Defined in: core/items/item.ts:667
See: #core/IItemLayout#getRotateX getRotateX
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IItemLayout.getRotateX
getRotateY
Section titled “getRotateY”getRotateY: () =>
Promise<number>
Defined in: core/items/item.ts:662
See: #core/IItemLayout#getRotateY getRotateY
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IItemLayout.getRotateY
getRotateZ
Section titled “getRotateZ”getRotateZ: () =>
Promise<number>
Defined in: core/items/item.ts:672
See: #core/IItemLayout#getRotateZ getRotateZ
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”IItemLayout.getRotateZ
getType
Section titled “getType”getType: () =>
Promise<ItemTypes>
Defined in: core/items/item.ts:786
See: #core/Source#getType getType
Returns
Section titled “Returns”Promise<ItemTypes>
Implementation of
Section titled “Implementation of”ISource.getType
Overrides
Section titled “Overrides”getValue
Section titled “getValue”getValue: () =>
Promise<string|XML>
Defined in: core/items/item.ts:763
See: #core/Source#getValue getValue
Returns
Section titled “Returns”Promise<string | XML>
Implementation of
Section titled “Implementation of”ISource.getValue
Overrides
Section titled “Overrides”isEnhancedResizeEnabled
Section titled “isEnhancedResizeEnabled”isEnhancedResizeEnabled: () =>
Promise<boolean>
Defined in: core/items/item.ts:637
See: #core/IItemLayout#isEnhancedResizeEnabled isEnhancedResizeEnabled
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IItemLayout.isEnhancedResizeEnabled
isKeepAspectRatio
Section titled “isKeepAspectRatio”isKeepAspectRatio: () =>
Promise<boolean>
Defined in: core/items/item.ts:627
See: #core/IItemLayout#isKeepAspectRatio isKeepAspectRatio
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IItemLayout.isKeepAspectRatio
isPositionLocked
Section titled “isPositionLocked”isPositionLocked: () =>
Promise<boolean>
Defined in: core/items/item.ts:632
See: #core/IItemLayout#isPositionLocked isPositionLocked
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”IItemLayout.isPositionLocked
refresh
Section titled “refresh”refresh: () =>
Promise<Source>
Defined in: core/items/item.ts:783
See: #core/Source#refresh refresh
Returns
Section titled “Returns”Promise<Source>
Implementation of
Section titled “Implementation of”ISource.refresh
Overrides
Section titled “Overrides”sendBackward
Section titled “sendBackward”sendBackward: () =>
Promise<Item>
Defined in: core/items/item.ts:677
See: #core/IItemLayout#sendBackward sendBackward
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.sendBackward
sendToBack
Section titled “sendToBack”sendToBack: () =>
Promise<Item>
Defined in: core/items/item.ts:682
See: #core/IItemLayout#sendToBack sendToBack
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.sendToBack
setCanvasRotate
Section titled “setCanvasRotate”setCanvasRotate: (
value) =>Promise<Item>
Defined in: core/items/item.ts:687
See: #core/IItemLayout#setCanvasRotate setCanvasRotate
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setCanvasRotate
setCropping
Section titled “setCropping”setCropping: (
value) =>Promise<Item>
Defined in: core/items/item.ts:692
See: #core/IItemLayout#setCropping setCropping
Parameters
Section titled “Parameters”Object
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setCropping
setCroppingEnhanced
Section titled “setCroppingEnhanced”setCroppingEnhanced: (
value) =>Promise<Item>
Defined in: core/items/item.ts:697
See: #core/IItemLayout#setCroppingEnhanced setCroppingEnhanced
Parameters
Section titled “Parameters”Object
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setCroppingEnhanced
setCustomName
Section titled “setCustomName”setCustomName: () =>
Promise<Item>
Defined in: core/items/item.ts:753
See: #core/Source#setCustomName setCustomName
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”ISource.setCustomName
Overrides
Section titled “Overrides”setEnhancedResizeEnabled
Section titled “setEnhancedResizeEnabled”setEnhancedResizeEnabled: (
value) =>Promise<Item>
Defined in: core/items/item.ts:717
See: #core/IItemLayout#setEnhancedResizeEnabled setEnhancedResizeEnabled
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setEnhancedResizeEnabled
setEnhancedRotate
Section titled “setEnhancedRotate”setEnhancedRotate: (
value) =>Promise<Item>
Defined in: core/items/item.ts:702
See: #core/IItemLayout#setEnhancedRotate setEnhancedRotate
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setEnhancedRotate
setKeepAspectRatio
Section titled “setKeepAspectRatio”setKeepAspectRatio: (
value) =>Promise<Item>
Defined in: core/items/item.ts:707
See: #core/IItemLayout#setKeepAspectRatio setKeepAspectRatio
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setKeepAspectRatio
setKeepLoaded
Section titled “setKeepLoaded”setKeepLoaded: (
value) =>Promise<Item>
Defined in: core/items/item.ts:778
See: #core/Source#setKeepLoaded setKeepLoaded
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”ISource.setKeepLoaded
Overrides
Section titled “Overrides”setName
Section titled “setName”setName: (
value) =>Promise<Item>
Defined in: core/items/item.ts:743
See: #core/Source#setName setName
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”ISource.setName
Overrides
Section titled “Overrides”setPosition
Section titled “setPosition”setPosition: (
value) =>Promise<Item>
Defined in: core/items/item.ts:722
See: #core/IItemLayout#setPosition setPosition
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setPosition
setPositionLocked
Section titled “setPositionLocked”setPositionLocked: (
value) =>Promise<Item>
Defined in: core/items/item.ts:712
See: #core/IItemLayout#setPositionLocked setPositionLocked
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setPositionLocked
setRotateX
Section titled “setRotateX”setRotateX: (
value) =>Promise<Item>
Defined in: core/items/item.ts:732
See: #core/IItemLayout#setRotateX setRotateX
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setRotateX
setRotateY
Section titled “setRotateY”setRotateY: (
value) =>Promise<Item>
Defined in: core/items/item.ts:727
See: #core/IItemLayout#setRotateY setRotateY
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setRotateY
setRotateZ
Section titled “setRotateZ”setRotateZ: (
value) =>Promise<Item>
Defined in: core/items/item.ts:737
See: #core/IItemLayout#setRotateZ setRotateZ
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”IItemLayout.setRotateZ
setValue
Section titled “setValue”setValue: (
value) =>Promise<Item>
Defined in: core/items/item.ts:768
See: #core/Source#setValue setValue
Parameters
Section titled “Parameters”string | XML
Returns
Section titled “Returns”Promise<Item>
Implementation of
Section titled “Implementation of”ISource.setValue
Overrides
Section titled “Overrides”_emitter
Section titled “_emitter”
static_emitter:EventEmitter
Defined in: core/items/item.ts:85
_subscriptions
Section titled “_subscriptions”
static_subscriptions:any[] =[]
Defined in: core/items/item.ts:86
Methods
Section titled “Methods”duplicate()
Section titled “duplicate()”duplicate(
options?):Promise<Item>
Defined in: core/items/item.ts:416
param: (options: {linked?:
return: Promise<Item>Duplicate an item into the current scene or to a specified scene as Linked or Unlinked.
Linked items would generally have a single source, and any changes in the property of an item would be applied to all linked items.
Chainable
// item pertains to an actual Item instance// Sample 1item.duplicate() // duplicate selected item to the current scene as unlinkedDuplicate the selected item to a specific scene and set it to be linked to a single source with the original item.
// Sample 2var toScene = xjs.Scene.getById(2)item.duplicate({linked:true, scene:toScene})Parameters
Section titled “Parameters”options?
Section titled “options?”linked?
Section titled “linked?”boolean
scene?
Section titled “scene?”number | Scene
Returns
Section titled “Returns”Promise<Item>
getFPS()
Section titled “getFPS()”getFPS():
Promise<number>
Defined in: core/items/item.ts:282
return: Promise
Get the frames rendered per second of an item
item.getFPS().then(function(fps) { // The rest of your code here});Returns
Section titled “Returns”Promise<number>
getParentItem()
Section titled “getParentItem()”getParentItem():
Promise<Item>
Defined in: core/items/item.ts:587
return: Promise
Get the GroupItem that contains this item. This rejects if item is not a child item or non-existent
item.getParentItem().then(function(parentItem) { console.log(parentItem);});Returns
Section titled “Returns”Promise<Item>
getSceneId()
Section titled “getSceneId()”getSceneId():
Promise<string|number>
Defined in: core/items/item.ts:351
return: Promise<number|string>
Get (1-indexed) Scene ID where the source is loaded
source.getSceneId().then(function(id) { // The rest of your code here});Returns
Section titled “Returns”Promise<string | number>
getSource()
Section titled “getSource()”getSource():
Promise<Source>
Defined in: core/items/item.ts:530
return: Promise
Gets the Source of an item, linked items would only have 1 source.
Chainable
item.getSource().then(function(source) { //Manipulate source here source.setName('New Name')})Returns
Section titled “Returns”Promise<Source>
getView()
Section titled “getView()”getView():
Promise<ViewTypes>
Defined in: core/items/item.ts:320
return: Promise
Get the view type of the item
item.getView().then(function(view) { // view values: // 0 = main view // 1 = preview editor // 2 = thumbnail preview})Returns
Section titled “Returns”Promise<ViewTypes>
isChildItem()
Section titled “isChildItem()”isChildItem():
Promise<boolean>
Defined in: core/items/item.ts:558
return: Promise
Checks if item is part of a group
item.isChildItem().then(function(isChild) { console.log(isChild);});Returns
Section titled “Returns”Promise<boolean>
off(
event,handler):void
Defined in: core/items/item.ts:224
param: (event: string, handler: Function)
Removes specificied event handler bound by on.
Note that this can only be done for named function handlers.
Usage:
Section titled “Usage:”let itemChange = function(...args) { console.log('Item has changed');}
let current;let items;xjs.Scene.getActiveScene().then( scene => { current = scene; return current.getItems();}).then( list => { items = list; items[0].on('item-changed', itemChange); setTimeout( ()=> { items[0].off('item-changed', itemChange); }, 10000);});Parameters
Section titled “Parameters”string
handler
Section titled “handler”Function
Returns
Section titled “Returns”void
on(
event,handler):void
Defined in: core/items/item.ts:126
param: (event: string, handler: Function)
Allows listening to events per instance.
Currently there are only two:
item-changed and item-destroyed.
Item change is triggered thru any property change:
- via js(source plugin/extension),
- via visibility-toggling through the sources list,
- or via the source properties dialog
Usage:
Section titled “Usage:”let itemChange = function(...args) { console.log('Item has changed');}
let current;let items;xjs.Scene.getActiveScene().then( scene => { current = scene; return current.getItems();}).then( list => { items = list; items[0].on('item-changed', itemChange);});Duplicate handlers are allowed.
Parameters
Section titled “Parameters”string
handler
Section titled “handler”Function
Returns
Section titled “Returns”void
remove()
Section titled “remove()”remove():
Promise<boolean>
Defined in: core/items/item.ts:504
return: Promise
Removes selected item
item.remove()Returns
Section titled “Returns”Promise<boolean>
toXML()
Section titled “toXML()”toXML():
XML
Defined in: core/items/item.ts:373
return: XML
Convert the Item object to an XML object. Use toString() to
get the string version of the returned object.
var xml = item.toXML();Returns
Section titled “Returns”XML
unlink()
Section titled “unlink()”unlink():
Promise<Item>
Defined in: core/items/item.ts:486
return: Promise
Unlinks selected item.
Unlinks an item to the source of other linked items and renders its own source.
item.unlink()Note: Once you unlink an Item, there’s still no method to reverse the process.
Returns
Section titled “Returns”Promise<Item>
getAllSources()
Section titled “getAllSources()”
staticgetAllSources():Promise<Source[]>
Defined in: core/source/source.ts:220
return: Promise<Source[]>
Get all unique Source from every scene.
Total number of Sources returned may be less than total number of items on
all the scenes due to Linked items only having a single Source.
xjs.Source.getAllSources().then(function(sources) { for(var i = 0 ; i < sources.length ; i++) { if(sources[i] instanceof xjs.HtmlSource) { // Manipulate HTML Source here } }})Returns
Section titled “Returns”Promise<Source[]>
Inherited from
Section titled “Inherited from”getCurrentSource()
Section titled “getCurrentSource()”
staticgetCurrentSource():Promise<Source>
Defined in: core/source/source.ts:108
return: Promise
Get the current source (when function is called by sources), or the source that was right-clicked to open the source properties window (when function is called from the source properties window)
xjs.Source.getCurrentSource().then(function(source) { // This will fetch the current source (the plugin)}).catch(function(err) { // Handle the error here. Errors would only occur // if we try to execute this method on Extension plugins});Returns
Section titled “Returns”Promise<Source>
Inherited from
Section titled “Inherited from”getItemList()
Section titled “getItemList()”
staticgetItemList():Promise<Item[]>
Defined in: core/items/item.ts:248
return: Promise<Item[]>
Gets the list of linked items of the current Item. Linked items are items linked to a single source.
xjs.Item.getItemList().then(function(items) { for (var i = 0 ; i < items.length ; i++) { // Manipulate each item here items[i].setKeepAspectRatio(true); }})This is simply a shortcut to:
xjs.Item.getCurrentSource() -> source.getItemList()
Returns
Section titled “Returns”Promise<Item[]>