Triggered after the view state changes. This event enables post-change logic such as analytics, UI updates, or side effects.
Event properties
The reason for the view change.
Whether the launcher was visible.
Whether the main window was visible.
Whether the launcher is now visible.
Whether the main window is now visible.
Example
instance.on('view:change', (event, instance) => {
console.log('View changed:', {
reason: event.reason,
from: event.oldViewState,
to: event.newViewState
});
// Remove transition CSS class
document.body.classList.remove('chat-view-changing');
// Track analytics
if (event.newViewState.mainWindow && !event.oldViewState.mainWindow) {
analytics.track('chat_opened', { reason: event.reason });
}
// Adjust page layout
if (event.newViewState.mainWindow) {
adjustPageLayout('chat-open');
} else {
adjustPageLayout('chat-closed');
}
});
Do you need practical examples?
Learn how to apply the features available for embedded chat into your implementation with guidance and examples.