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

Mittwoch, 18. April 2018, 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

Mittwoch, 18. April 2018, 21:29

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

JS:

Quellcode

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


XML:

Quellcode

1
events.dispatch("my_custom_event_when_something_is_done");

5

Donnerstag, 26. April 2018, 14:52

Hello Klaus,

This works and meets my intention, but only in Html5 mode ! Your alert is not displayed when using Flash.

Also, it does not allow multiple listening functions, eg:

Quellcode

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


...only the SECOND alert will display (although adding multiple listening functions could be extended with some code).

Also, I dont see how custom data could be passed during the event dispatch (although this could also be extended with some krpano.call() code during the event listening functions).

But the flash limitation blocks the use of this feature? How to get this working in flash mode?

Thank you !