You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, March 30th 2018, 3:24pm

[solved] drag fonction bug on mobile

Hi !
On mobile, the layer don't take the touch position in real time , and stop !

desktop it's works ... any idea ?

<layer name="test" type="text" html="test-drag" edge="center" align="topleft" bg="true" bgcapture="false" capture="true" handcursor="true" selectable="true"
height="20" width="100" vcenter="true" zorder="100" parent="blockFp"
ondown="dragTest(get(name),true);"
onup="dragTest(get(name),false);"

/>


<action name="dragTest" scope="local" args="layerhp,boolean">
if(boolean,
screentolayer(blockFp,mouse.stagex,mouse.stagey,lx,ly);
set(layer[get(layerhp)].x,get(lx));
set(layer[get(layerhp)].y,get(ly));

delayedcall(testFollow,0.01,
dragTest(get(layerhp),true);
);
,
stopdelayedcall(testFollow);
);
</action>


same issue with asyncloop:

<action name="dragTest" scope="local" args="layerhp">
showlog();
asyncloop(global.dragtestlayer,
screentolayer(blockFp,mouse.stagex,mouse.stagey,lx,ly);
set(layer[get(layerhp)].x,get(lx));
set(layer[get(layerhp)].y,get(ly));
);
</action>

on mobile it return the x/y pos of blockFp and stop

layer blockFp is parent="STAGE" and is outside area

This post has been edited 5 times, last edit by "MrTie" (Apr 3rd 2018, 11:22am)


2

Friday, March 30th 2018, 4:41pm

ok that's it, if block not parent="STAGE" it works good... but i need parent="STAGE" any solution ?

3

Tuesday, April 3rd 2018, 11:19am

added in js

Source code

1
2
3
4
5
6
7
8
9
function doTouch(e) {    e.preventDefault();
    var touch = e.touches[0];

    krpano.set('touchX',touch.screenX);
    krpano.set('touchY',touch.screenY);
}

krpano.addEventListener('touchstart', function(e) {doTouch(e);}, false);
krpano.addEventListener('touchmove', function(e) {doTouch(e);}, false);



and do this on my drag function :


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<action name="HpFollowMouse" scope="local" args="layerhp, layerplan, rl,boolean">   if(boolean,
       if(device.desktop,
          screentolayer(get(layerplan),mouse.stagex,mouse.stagey,lx,ly);
          ,
          screentolayer(get(layerplan),touchX,touchY,lx,ly);
       );
       set(layer[get(layerhp)].x,get(lx));
       set(layer[get(layerhp)].y,get(ly));
       if(rl,
        set(plugin[radar].x,get(lx));
        set(plugin[radar].y,get(ly));
       );

   delayedcall(HpFpFollow,0.01,
      HpFollowMouse(get(layerhp),get(layerplan),get(rl),true);
   );
   ,
   stopdelayedcall(HpFpFollow);
  );
</action>


because the mouse position only work inside area and not outside area + (layer parent = stage) on mobile :)

This post has been edited 1 times, last edit by "MrTie" (Apr 3rd 2018, 11:48am)