Developer Portal
Quick StartsComposition scriptingAPIs and SDKsSupport
  • Portal overview
  • Quick start
  • REST API
    • Introduction
    • Rate limits
    • Authorization
    • How-to guides
      • Get a control app's API token
      • Get a composition's sub-composition IDs and names and their payload structures
      • Get a control app's model
      • Get a control app's metadata
      • Update a sub-composition's content
      • Update a sub-composition's animation state
      • Update a sub-composition's content and animation state in one call
      • Update multiple sub-compositions in one call
    • API reference
      • Get control app details
        • Get a control app's metadata
        • Get a control app's model
        • Get a control app's control data
      • Send data to a control app
        • Update a control app's content
        • Update a control app's animation state
      • Take out all of an app's output
  • Data stream API
    • Introduction
    • Rate limits
    • Authorization
    • How-to guides
      • Create a data stream
      • Link a data stream to a composition
      • Send data to an app using the data stream API
    • API reference
  • Composition scripting
    • Introduction
    • Overview
    • Quick start
      • Find sub-compositions and widgets
      • Read and update control nodes
      • Set text widget text properties
      • Read and update widget properties
      • Read control nodes and update widget properties
      • Set image widget URL property
      • Set table widget content property
    • Cheat sheets
      • Fundamentals
      • Interactive overlays
      • Best practices
    • Use cases
      • Read control nodes and generate HTML text
      • Read control nodes, generate HTML text with background
      • Text Ticker - Start ticker on "In" animation
    • Composition script editor reference
  • Software development kits
    • Graphics SDK
      • Getting started
      • Reference
        • SDK functions
        • Composition object
        • Sequencer object
      • Guides and examples
        • Load a composition with its token
        • Load a composition with its URL
        • Get the composition URL of an app instance
        • Sequencer VOD example
        • Control local preview of app
        • Load app instance output
    • Overlay SDK
      • Getting started
      • SDK functions
      • Use case examples
    • Widget SDK
      • Preparing your environment
      • Getting started
      • Reference
        • Widget UI definition
        • Widget callback functions
        • Time control object
        • Composition instance
      • Guides and examples
        • Widget example: CSS patterns
    • App SDK
  • Singular Basics
    • Overview of Singular
    • Managing overlays in the Dashboard
      • How to create a new composition
      • How to open a new app template
      • How to create an app for a composition
      • How to extract a composition from an app
      • How to find an app's shared app token and shared API URL
      • Dashboard reference
    • Building overlays in Composer
      • How to build a composition
      • How to set up layer logic to automate overlay transitions
      • How to set up control nodes to make widget properties available to a control app
      • Animating overlays
        • How to create timeline animations
        • How to create behavior animations
        • How to create update animations
      • How to make overlays interactive
      • How to adapt overlays to various screen sizes
      • Composer reference
    • Controlling overlays in Studio and UNO
      • How to use Studio
      • Studio reference
      • UNO reference
  • Support
    • Singular status
    • Support resources
    • Singular terminology
    • Performance Testing
Powered by GitBook
On this page
  • Properties
  • Methods
  • animate()
  • destroy()
  • getDuration()
  • is2Timeline()
  • jumpTo()
  • playTo()
  • resize()
  • seek()
  • setControlNode()
  • setWidgetNode()
  • stop()

Was this helpful?

  1. Software development kits
  2. Widget SDK
  3. Reference

Composition instance

compInstance: {onAirRefId: '56344bcd-9b83-43e2-863b-a5e5fde60c4f', getDuration: ƒ,  is2Timeline: ƒ, …}
> animate: ƒ (t)
> destroy: ƒ ()
> getDuration: ƒ ()
> is2Timeline: ƒ ()
> jumpTo: ƒ (t)
> onAirRefId: "56344bcd-9b83-43e2-863b-a5e5fde60c4f"
> playTo: ƒ (t,i)
> resize: ƒ (t,e)
> seek: ƒ (t,i)
> setControlNode: ƒ (t)
> setWidgetNode: ƒ (t)
> stop: ƒ ()

Properties

Name
Type
Example
Description

onAirRefId

String

"56344bcd-9b83-43e2-863b-a5e5fde60c4f"

The ID of the sub-composition that contains the widget.

Methods

animate()

Animates a composition instance using the event object(t) produced by an onAnimation callback.

destroy()

Destroys a composition instance.

// The code below destroys a composition instance

// check if composition instance exists
if (compInstance!= null) {
  compInstance.destroy();
  compInstance= null;
}

Return

none

getDuration()

Returns the duration of the In and Out animation timelines.

// The code below prints the animation durations to the console
const animDuration = compInstance.getDuration();
console.log("animDuration =", animDuration);

Return

object: JSON object

animationDuration = {
  In: 1.3,
  Out: 0.5
}

is2Timeline()

Returns if a composition instance has one or two timelines.

// The code below prints the return value
const has2Timelines = compInstance.is2Timeline();
console.log("has2Timelines =", has2Timelines);

Return

boolean : false , has single timeline; true, has two timelines

has2Timelines = true

jumpTo()

Jumps to a specified animation state.

Parameter

Name
Type
Description

toState

String

In: jump to "In" state Out: jump to "Out" state

const toState = "In";
compInstance.jumpTo(toState);

playTo()

Plays the animation to the specified state.

Parameter

Name
Type
Description

toState

String

In: jump to "In" state Out: jump to "Out" state

const toState = "In";
compInstance.playTo(toState);

resize()

Resizes a composition instance when a window size changes.

/**
 * addEventListener for window resizing
 */
window.addEventListener("resize", function() {
    if (windowWidth != window.innerWidth || windowHeight != window.innerHeight) {
        windowWidth = window.innerWidth;
        windowHeight = window.innerHeight;
        if (compInstance) {
            compInstance.resize(windowWidth, windowHeight);
        }
    }
});

Return

none

seek()

Seeks the timeline to the specified time in [s].

Parameter

Name
Type
Description

t

Number

Time in [s].

const t = 1.5; // 1.5 [s]
compInstance.seek(t);

Return

none

setControlNode()

Sets the content of control nodes defined in a composition instance.

Users can manually define control nodes in widget compositions.

Parameter

Name
Type
Description

payload

JSON

A payload that contains control node content.

// The code below sets content of the control nodes "Pos", "Name", and "Age" in the composition instance.
const payload = {
  "Pos": 1,
  "Name": "John Doe",
  "Age": "32"
};

compInstance.setControlNode(payload);

Return

none

setWidgetNode()

Sets the content of widget nodes defined in a composition instance.

Widget nodes are created programmatically and managed by the widget dynamically.

Parameter

Name
Type
Description

payload

JSON

A payload containing widget node content.


// The code below sets content of the widget nodes "id", "longitude", "latitude", and "temperature" in the composition instance.
const payload = {
  "id": 1001,
  "longitude": 45.67,
  "latitude": 18.97,
  "temperature": "25°C"
};

compInstance.setWidgetNode(payload);

Return

none

stop()

Stops a widget animation.

PreviousTime control objectNextGuides and examples

Last updated 2 years ago

Was this helpful?