partey_workadventure/front/src/Api/iframe/Navigation.ts

35 lines
844 B
TypeScript
Raw Normal View History

import type { GoToPageEvent } from '../Events/GoToPageEvent';
import type { OpenTabEvent } from '../Events/OpenTabEvent';
import { IframeApiContribution, sendToWorkadventure } from './IframeApiContribution';
class WorkadventureNavigationCommands extends IframeApiContribution<WorkadventureNavigationCommands> {
readonly subObjectIdentifier = "nav"
readonly addMethodsAtRoot = true
callbacks = []
openTab(url: string): void {
sendToWorkadventure({
"type": 'openTab',
"data": {
url
} as OpenTabEvent
});
}
goToPage(url: string): void {
sendToWorkadventure({
"type": 'goToPage',
"data": {
url
} as GoToPageEvent
});
}
}
export default new WorkadventureNavigationCommands();