Having a productive weekend :D

Having a productive weekend πŸ˜€

Here’s something I had in my mind for some time.

Enables 8 instead of 4 gestures.

needs infinte scrolling and diagonal scrolling.

script in first comment for easy copying.ο»Ώ

Thanks to TrianguloY, I stole your sessiontoken πŸ˜›

]]>
« (Previous Post)

23 Commentsto Having a productive weekend :D

  1. Anonymous says:

    < ![CDATA[

    var e=LL.getEvent();


    var c=e.getContainer();



    var sessiontoken;


    do{


    sessiontoken=””+Math.random();


    }while(sessiontoken==c.getTag());


    c.setTag(sessiontoken);


    setTimeout(f,50);



    function f()


    {


    if(c.getTag()==sessiontoken)


    {


    var x=c.getPositionX();


    var y=c.getPositionY();


    var output=”error”;


    if(x/y>0.5&&x/y<2)


    {


    if(x<0)output="upper left";


    else output=”lower right”;


    }


    else if(x/y< -0.5&&x/y>-2)


    {


    if(x<0)output="lower left";


    else output=”upper right”;


    }


    else if(x/Math.abs(y)>=2)output=”right”;


    else if(x/Math.abs(y)< =-2)output="left";


    else if(y<0)output="top";


    else output=”bottom”;


    Android.makeNewToast(output,true).show();


    c.setPosition(0,0,1,false);


    //LL.writeToLogFile(output+”\n”,true);


    }


    }

    ]]>

  2. Anonymous says:

    < ![CDATA[

    My sessiontoken :’)



    Nice job, however it waits until show the Toast…why?


    I mean, with your script you are scrolling the container, and you don’t need to. Why did you choose this way? (I’ll show you my version after)

    ]]>

  3. Anonymous says:

    < ![CDATA[

    it waits until the gesture is finsished, so gestures aren’t detected double.



    oh theres a debug line… ill comment it out

    ]]>

  4. Anonymous says:

    < ![CDATA[

    I removed the writetolog before try πŸ˜‰



    I see the sessiontoken to avoid running multiple instances(there is a better way), but I ask why you don’t just take the position and set to the origin again instantly, so you don’t see the container scrolled.



    It is better with an example, however my mobile is dead (only battery πŸ˜‰ so I’ll post here my custom script tomorrow, sorry.

    ]]>

  5. Anonymous says:

    < ![CDATA[

    The sessiontoken is not there to avoid multiple instances, but to determine when no events are fired anymore, so when the gesture is finished.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Yes, sorry. I expressed myself bad.


    What I wanted to say, is that your script is setting timeouts to run f() after little time, but only the last executed one runs, the others just stop. (If I’m not wrong, correct me if I am)



    Ok, this next comment is my script. It’s something I made so it’s very different from yours, however the output is more or less the same.



    It has two differences:


    It executes the script the first time, and waits until you stop scrolling. This is the opposite of yours.



    The output is the angle in degrees [0-360) but I converted it to your 8-direction output.



    I hope you’ll find this useful, as usual πŸ˜‰



    (Little note: did you tried to set the container to the origin every time, to avoid seeing the container scrolled? It is a bit less precise, however I think it is still fine. You can check it with my script)

    ]]>

  7. Anonymous says:

    < ![CDATA[

    var e=LL.getEvent();


    var now=e.getDate();


    var bef=LL.getScriptTag()||0;


    LL.setScriptTag(now);


    var cont=e.getContainer();



    if(now-bef>250){



    var x= -cont.getPositionX() , y= -cont.getPositionY();



    var long = Math.sqrt(x*x+y*y);



    var angle = Math.acos(x/long)*180/Math.PI;


    if(y>0)angle=-angle+360;



    var text=””;


    //text=angle+” _ “+ long;



    var directions=[“left”,”down left”,”down”,”down right”,”right”,”up right”,”up”,”up left”];


    text+=directions[Math.floor(((angle+22.5)%360)/360*8)];


    text+=” – “;


    text+=long>100?”long”:”short”;



    Android.makeNewToast(text,true).show();



    }




    cont.setPosition(0,0,1,false);

    ]]>

  8. Anonymous says:

    < ![CDATA[

    It always says short for me. what exactly is the difference between short and long?

    ]]>

  9. Anonymous says:

    < ![CDATA[

    How much you scroll.


    Try scrolling fast from side to side


    Also you can modify it to show the long variable, perhaps 100 is too much for you.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    I set it to 40, seems to be good for me.


    But can’t you compute that somehow out of desktop width/height?

    ]]>

  11. Anonymous says:

    < ![CDATA[

    I guess yes.


    However as I said this was something I had, but never finished it.


    It’s mainly for you now, if you want.


    As you see the output is the angle, so theoretically you can perform 4,8,16,32…the number of different directions you want (but the more, the less precise) and the long/short was something to test, not important.

    ]]>

  12. Anonymous says:

    < ![CDATA[

    I love reading these 2 guys jibber jabber cause I know at the end I get to play with whatever they come up with. Keep it up guys, I appreciate the time and effort you put into scripting. Cheers.

    ]]>

  13. Anonymous says:

    < ![CDATA[

    TrianguloY is there a possibility to compute the whole scrolled distance in your script?

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Hmm, yes theoretically.


    With your timeout idea you can keep adding the distance until the user stop scrolling…hey! Good idea. This will allow to have your better precision with my 360Β° output without seeing the container scrolled.



    Do you want to do it yourself or prefer me to do it?

    ]]>

  15. Anonymous says:

    < ![CDATA[

    Ok, I did it and discovered that the getPosition return the scrolled distance from the origin, even if you set the position to somewhere from script.


    I also modified it to say ‘short/long’ based on the screen size:


    ( Lukas Morawietz, you can uncomment the line of the ‘marker’ item to see what I mean)ο»Ώ



    Oh, and also I used ‘this’ to store the sessiontoken, it seems to work fine

    ]]>

  16. Anonymous says:

    < ![CDATA[

    var e=LL.getEvent();


    var cont=e.getContainer();


    var dist=[cont.getPositionX() , cont.getPositionY()];


    cont.setPosition(0,0,1,false);


    //cont.getItemByLabel(“marker”).setPosition(dist[0],dist[1]);




    var sessiontoken;


    do{


    sessiontoken=””+Math.random();


    }while(sessiontoken==this.tok);


    this.tok=sessiontoken;


    setTimeout(f,50);



    function f()


    {


    if(this.tok!=sessiontoken)return;




    var x= -dist[0]/cont.getWidth() , y= -dist[1]/cont.getHeight();




    var long = Math.sqrt(x*x+y*y);



    var angle = Math.acos(x/long)*180/Math.PI;


    if(y>0)angle=-angle+360;



    var text=””;


    //text=angle+” _ “+ long;


    //text=x+”_”+y;



    var directions=[“left”,”down left”,”down”,”down right”,”right”,”up right”,”up”,”up left”];


    text+=directions[Math.floor(((angle+22.5)%360)/360*8)];


    text+=” – “;


    text+=long>0.5?”long”:”short”;




    Android.makeNewToast(text,true).show();



    }

    ]]>

  17. Anonymous says:

    < ![CDATA[

    I’m thinking of free gestures. Any ideas? Something like draw a circle, rectangle, z-form, etc.

    ]]>

  18. Anonymous says:

    < ![CDATA[

    That’s exactly what I thought once.


    This will need extra scripting…let’s go!


    First we need to store the data of the scrolling so we can then say which geometry it is.


    Perhaps just your 8-directional output? What will be the difference between a circle and a square? (And also the precision of the events are something to keep in mind…)ο»Ώ

    ]]>

  19. Anonymous says:

    < ![CDATA[

    I thought about capturing an Array of points, and then compare it to the initial gesture Array…

    ]]>

  20. Anonymous says:

    < ![CDATA[

    The problem of an array of points is what points. The easiest list is just the points given by the positionchange refresh, but maybe this depends on how fast the device is.


    Also then that’s difficult to compare I think.


    A solution will be to only store the ‘corners’, but of course no one can make exact lines so we need to decide if a line is the continuation of the previous one or a new one…

    ]]>

  21. Anonymous says:

    < ![CDATA[

    Lukas Morawietz, I tried this: take your 8 directional output (without repetitions) and store them in a list. After you performed the action the list is shown (or custom action if needed)


    It works better than I expected…Try it (just set as usual, but enable free scrolling otherwise it will make false movements)

    ]]>

  22. Anonymous says:

    < ![CDATA[

    var sensitivity = 0.1; //percentage




    var e=LL.getEvent();


    var cont=e.getContainer();



    var now=[cont.getPositionX() , cont.getPositionY()];


    cont.setPosition(0,0,1,false);


    this.prev=this.prev||[0,0];


    var dist = [now[0]-this.prev[0],now[1]-this.prev[1]];



    //cont.getItemByLabel(“marker”).setPosition(dist[0]+cont.getWidth()/2,dist[1]+cont.getHeight()/2);



    //calculus mode


    var x= -dist[0]/cont.getWidth() , y= -dist[1]/cont.getHeight();




    var long = Math.sqrt(x*x+y*y);



    if(long>sensitivity){



    this.prev=now;



    var angle = Math.acos(x/long)*180/Math.PI;


    if(y>0)angle=-angle+360;



    var text=””;


    //text=angle+” _ “+ long;


    //text=x+”_”+y;



    var directions=[“β†’”,”β†—”,”↑”,”β†–”,”←”,”↙”,”↓”,”β†˜”];


    text+=directions[Math.floor(((angle+22.5)%360)/360*8)];



    this.list=this.list||[“”];



    if(this.list[this.list.length-1]!=text)this.list[this.list.length]=text;



    }



    var sessiontoken;


    do{


    sessiontoken=””+Math.random();


    }while(sessiontoken==this.tok);


    this.tok=sessiontoken;


    setTimeout(f,50);



    function f()


    {


    if(this.tok!=sessiontoken)return;





    var toshow=””;


    for(var i=0;i



    this.list=[“”];


    this.prev=[0,0];



    alert(toshow);


    }ο»Ώ

    ]]>

  23. Anonymous says:

    < ![CDATA[

    Seems not too bad. Now we have to match it to previsiously defined gestures

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *