Events

Get notified when Spirit Studio connects and disconnects:

window.addEventListener('connect-spirit', () => {
  console.log('Spirit Studio connected');
});

window.addEventListener('disconnect-spirit', () => {
  console.log('Spirit Studio disconnected');
});

Groups

Get notified when groups are added

spirit.groups.on('add', (group) => {
  console.log(`Group ${group.name} has been added`);
});

Get notified when groups are removed

spirit.groups.on('remove', (group) => {
  console.log(`Group ${group.name} has been removed`);
});
Group

Group

const group = spirit.groups.get('clock');

Listen to timeline construction

group.on('construct', (timeline) => {
  console.log(`Timeline is constructed for group "clock"`, timeline);
  timeline.reverse().repeat(2);
});

Listen to all changes

group.on('change', () => {
  console.log(`Some value has been changed for group "clock"`);
});

Listen to time scale changes

group.on('change:timeScale', () => {
  console.log(`timeScale has been changed to ${group.timeScale}`);
});

Listen to name changes

group.on('change:name', () => {
  console.log(`Name has been changed to ${group.name}`);
});

Listen for duration changes

group.on('change:duration', () => {
  console.log(`Duration has been changed to ${group.duration}`);
});
  • Spirit
  • Support
  • Terms