Switch GYROSCOPE custom code  

Share your tips and tricks here or get help with any Panotour 2.0+ problem!
No bug reports (of any kind) in this forum!
no avatar
dadoplus
Member
 
Topic author
Posts: 76
Likes: 30 posts
Liked in: 9 posts
Joined: Wed Mar 11, 2015 11:51 pm
Info

Switch GYROSCOPE custom code

by dadoplus » Mon Mar 19, 2018 4:21 am

Hi guys,
I need to switch gyroscope state with the same button (one of top menu plugin by alexpopov). Since the default action in panotour still needs 2 different "slots" and top menu does not support it, I was thinking of using call custom code action or call a javascript function but I can't seem to understand exactly the code to do the trick.
Any ideas? I thought this was the action but doesn't seem like it.
Code: Select all
<action name="changeGyroscopeState">
  if(plugin[gyroscope],
    if (plugin[gyroscope].isavailable,
        if(%1,
          set(plugin[gyroscope].activated,true);
        ,
          set(plugin[gyroscope].activated,false);
        );
        if (%1 != plugin[gyroscope].enabled,
          if(plugin[gyroscope].activated,
            switch(plugin[gyroscope].enabled);
          ,
            set(plugin[gyroscope].enabled, false);
          );
          if (plugin[gyroscope].enabled, events.dispatch(ongyroscopeon);, events.dispatch(ongyroscopeoff););
        );
    );
  );
</action>


Thanks!

no avatar
benji33
Kolor Team
 
Posts: 5848
Likes: 92 posts
Liked in: 199 posts
Joined: Tue Apr 09, 2013 10:59 am
Location: France
Info

Re: Switch GYROSCOPE custom code

by benji33 » Thu Mar 22, 2018 11:01 am

You would like a toggle rather than the Enable & Disable actions ?
It means: set activated to true is false prior and vice versa.

If yes, try this code.
Code: Select all
<action name="toggleGyroscope">
   if(plugin[gyroscope],if (plugin[gyroscope].isavailable,
      <!-- toggle gyroscope if activated in the tour -->
      if(plugin[gyroscope].activated,
         switch(plugin[gyroscope].enabled);
       ,
         set(plugin[gyroscope].enabled, false);
       );
      <!-- fire Panotour event for the current gyroscope state -->
      if (plugin[gyroscope].enabled,
         events.dispatch(ongyroscopeon);
      ,
         events.dispatch(ongyroscopeoff);
      );
   ););
</action>


Yes, you can call a krpano custom code or uses the third party plugin to add an XML file with your own code into.
Benjamin


Who is online

Users browsing this forum: No registered users and 6 guests

cron