Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Donnerstag, 12. April 2018, 22:45

Dispatching events from within XML to the webpage JS

Is it possible to call dispatch events to the webpage, from within the krpano xml file?

I am looking to dispatch eg. en event on the krpano object (that has been provided from embedpano/onready), with custom data, from within the loaded xml data.

The alternative currently working method, is to use js() within xml and use an event dispatcher proxy object on a global scope variable. This is not ideal, and gets complicated if an unknown number of krpano players are set.

Is it possible to dispatch events directly on the krpano object from within the krpano xml file?

2

Montag, 16. April 2018, 19:50

Sorry, but I don't understand what you mean... What kind of events?

3

Gestern, 19:55

I would like to do something like:

$(krpano).on("my-custom-event-when-something-is-done", function(event) {
alert("something was done inside the krpano player !");
});

...and inside the krpano xml, have something somewhere

events.trigger("my-custom-event-when-something-is-done");

...and even better with custom data.

In otherwords, I want to trigger a custom event inside the player, which will be received/listened to outside the krpano xml.

This would be useful if a specific button/hotspot was clicked inside the krpano player, but there were multiple instances of the krpano player running (and hence you cant just use the js() function to invoke something in the global scope of the document).

4

Gestern, 21:29

Sorry, still not sure what you what to do, but here your example ported to real code:

JS:

Source code

1
2
3
4
krpano.set("events.my_custom_event_when_something_is_done", function()
{
  alert("something was done inside the krpano player !");
});


XML:

Source code

1
events.dispatch("my_custom_event_when_something_is_done");