Page 1 of 1

Floorplan hotspots: howto react to "ondown"-event?  [SOLVED]

PostPosted: Mon Apr 17, 2017 1:17 am
by 360-compunics-com-ni
There is a special use case that requires all tour navigation to be executed by an "ondown"-event instead of the default "onclick"-event. In other words: the display of a pano shall be initiated when the mouse gets pressed over the navigation element, not when it afterwards gets released.
For buttons and hotpsots this has already been setup, i'm still looking for a way to achieve this for the floorplan hotspots.

This is what i have tried so far (with variations, for example tried an "addEventListener" instead of the "mousedown"):
Code: Select all
<events name="MapspotEvents" keep="true"
   onTourStart="callwhen(ptplugin[floorPlan].jsready, Init_{{plugname}}(); );"
/>

<action name="Init_{{plugname}}">
   {% for group in project.panoGroups %}{% for spot in group.mapFloorPlan.spots %}
      set(LinkedScene, get(ptplugin[floorPlan].floorplanItems[0].floorplanItem[fpitem{{group.tourId}}].spot[{{spot.tourId}}].scene) );
      setOndownEvent( {{spot.tourId}}, get(LinkedScene) );
   {% endfor %}{% endfor %}
</action>

<action name="setOndownEvent" type="Javascript"><![CDATA[
   jQuery('#'%1).mousedown('mainloadscene(%2));');
]]>
</action>

Any help would be greatly appreciated.

Re: Floorplan hotspots: howto react to "ondown"-event?

PostPosted: Mon Apr 17, 2017 3:10 am
by Destiny
Hi.. With Flash, if I were to add an "onclick="onclickspotpoint13" it would act on click.. So by rights it should already work...

Destiny...

Re: Floorplan hotspots: howto react to "ondown"-event?

PostPosted: Tue Apr 25, 2017 7:11 pm
by 360-compunics-com-ni
I finally figured out how to solve this issue:

Function definition in "index.html":
Code: Select all
   <script type="text/javascript">
   function setMapspotsOndownEvent(spotDIV)
   {
      var item = document.getElementById(spotDIV);
      item.addEventListener('mousedown', function(){ $('#'+spotDIV).trigger('click');}, false);
   }
   </script>

And the calling code of the plugin:
Code: Select all
<action name="SetMapspotsOndownEvent_{{plugname}}" keep="true">
   {% for group in project.panoGroups %}{% for spot in group.mapFloorPlan.spots %}
      txtadd(thisMapSpot, {{spot.tourId}}, '_img' );
      js( setMapspotsOndownEvent( get(thisMapSpot) ); );
   {% endfor %}{% endfor %}
</action>

This action needs to be called after the floorplan plugin has initialised on tourstart as follows:
Code: Select all
<events name="Events_{{plugname}}"  keep="true"
   onTourStart="callwhen(ptplugin[floorPlan].jsready, SetMapspotsOndownEvent_{{plugname}}(); );">
</events>