Simple Horizontal and Vertical page loop Updated again

Simple Horizontal and Vertical page loop Updated again

From Michael Plotke’s script (but fixed…sorry it was broken) I made this script to switch between the ‘sides’ of the container (very easy, feel free to improve it)

Instructions:

– Set it at the position changed event.

– Set the free scroll.

– Check the snap to pages! Otherwise you’ll get udesired results.

– IMPORTANT: try not to scroll while the animation is performing

– Comment any problem here.

——————————–

var e = LL.getEvent();

var c = e.getContainer();

var box = c.getBoundingBox();

if(c.getPositionScale()!=1)return;

var pos = [c.getPositionX(),c.getPositionY()];

var size = [c.getWidth(),c.getHeight()];

var limits = [ [box.getRight(),box.getLeft()],[box.getBottom(),box.getTop()] ];

var state = LL.getScriptTag() || “00”;

state=[state[0],state[1]];

var jump = [pos[0],pos[1]];

var glide = [pos[0],pos[1]];

for(var i=0;i<=1;++i){

if (pos[i] > limits[i][0]-size[i]/2 ) {

if(state[i]==”+”)return;

jump[i] = limits[i][1]-size[i]/2;

glide[i] = limits[i][1] ;

state[i] = “-“;

}else if (pos[i] < limits[i][1]-size[i]/2 ) {

if(state[i]==”-“)return;

jump[i] = limits[i][0]-size[i]/2 ;

glide[i] = limits[i][0]-size[i] ;

state[i]=”+”;

} else {

state[i] = “0”;

}

}

LL.setScriptTag(state[0]+state[1]);

if(state[0]!=”0″ || state[1]!=”0″){

c.setPosition( jump[0] , jump[1], 1, false);

c.setPosition(glide[0], glide[1], 1, true);

}

]]>

35 Commentsto Simple Horizontal and Vertical page loop Updated again

  1. Anonymous says:

    < ![CDATA[

    I am working on a script, which moves items with infinite scrolling, but this is cool too.

    ]]>

  2. Anonymous says:

    < ![CDATA[

    This only move the ‘camera’.


    This is not as smooth as move the items…but far easier.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    TrianguloY yes, i know, that’s why I’m working in the item movement.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    var d=LL.getCurrentDesktop();


    var dwidth=d.getWidth();


    var pos=d.getPositionX();


    var box=d.getBoundingBox();


    var min=box.getLeft();


    var max=box.getRight();


    var items=d.getItems();



    var setLeft=function()


    {


    for(x=0;x


    {


    var item=items.getAt(x);


    if(item.getPositionX()>=max-d.getWidth())


    {


    if(item.getProperties().getBoolean(“i.onGrid”))


    {


    var cell=item.getCell();


    item.setCell(cell.getLeft()-(max-min)/d.getCellWidth(),cell.getTop(),cell.getRight() -(max-min)/d.getCellWidth(),cell.getBottom());


    }


    else


    {


    item.setPosition(item.getPositionX()-max+min,item.getPositionY());


    }


    }


    }


    LL.setScriptTag(1);


    }



    var setRight =function()


    {


    for(x=0;x


    {


    var item=items.getAt(x);


    if(item.getPositionX()


    {


    if(item.getProperties().getBoolean(“i.onGrid”))


    {


    var cell=item.getCell();


    item.setCell(cell.getLeft()+(max-min)/d.getCellWidth(),cell.getTop(),cell.getRight() +(max-min)/d.getCellWidth(),cell.getBottom());


    }


    else


    {


    item.setPosition(item.getPositionX()+max-min,item.getPositionY());


    }


    }


    }


    LL.setScriptTag(0);


    }





    var pagepos=Math.floor(pos/dwidth)*dwidth


    if(Math.abs(pos-pagepos)<0.05 && parseInt(LL.getScriptTag())==1)


    {


    setRight();


    if(pagepos==min)


    {


    d.setPosition(max,0,1,false);


    }


    }


    else if(pos


    {


    setLeft();


    }


    else if(pos>max-dwidth)


    {


    setLeft();


    d.setPosition(min-dwidth,0,1,false);


    }




    It works most of the time, but sometimes the are weird things happening. 

    ]]>

  5. Anonymous says:

    < ![CDATA[

    TrianguloY: Woking well. Somethime i cannot from last right side back to more left.


    Somethime i go to right and i doing greater movement than i want and  now i am on absolutly left (I wanted only to the last page right). Vice versa have same problem (from right to more left).



    Bug… try please double tap… (doing zooming and now visible blank place. I can doing now only tap to back key.



    Please add to your script also from top to bottom and vice versa.



    I have been thinking about one thing…


    More conditions should include in script for infinity scrolling:



    1) when the phone is in portrait layout (for example grid: 6×6) and panel is horizontally (for example grid for panel 6×1) / we looking most left position and most right position



    2) when the phone is in portrait layout (for example grid: 6×6) and panel is vertically (for example grid for panel 1×6) / we looking most top position and most bottom



    3) When the phone is in landscape layout (for example grid: 9×4) and panel is horizontally (for example grid for panel 9×1) / we looking most left position and most right position



    4) when the phone is in landscape layout (for example grid: 9×4), and panel is vertically (for example grid for panel 1×4) / we looking most top position and most bottom position



    I hope you, you understand what I mean…

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Danbar Danbar Vertical loop, done.


    allow zoom, done (it won’t work if the zoom is not 1)


    About your suggestions…did you try it? it will work whatever the size of the desktop and the items are. Don’t forget to check ‘snap to pages’ and remove any old stop points.



    Lukas Morawietz: didn’t have time to check yours, but if it works I recommend to post it in a different post 😉

    ]]>

  7. Anonymous says:

    < ![CDATA[

    TrianguloY i just wanted to share a first build, because it’s still buggy. I don’t recommend to use it ATM

    ]]>

  8. Anonymous says:

    < ![CDATA[

    TrianguloY



    yes, i dont have stop point. I have set what you write in first post.



    I’ve tried it, it works both horizontally and vertically. 🙂



    But …


    If user is on screen most right. Just gently slide your finger to the right and immediately rotation is performed to absolutly left. I think it’s too fast forwarding (much too soon). I would add the condition that they must move items by more than x (in pixels or cells from last item) after crossing (this x size / free place without items) the start redirecting. Of course, vice versa (to left, to bottom, to top).

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Danbar Danbar that means an extremely different script I can’t do it now.


    Check Lucas’s script. That’s what you maybe need.



    And the most important thing: what you want is extremely difficult, don’t expect it, and be patient.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Danbar Danbar I changed it a bit, now the change is less inmediate, but you need the free scroll setting.



    IMPORTANT: try not to scroll while the animation is performing

    ]]>

  11. Anonymous says:

    < ![CDATA[

    I think it’s very simple.



    In the script you need to know:


    the last object left and right (you already know). (for looping – target)


    add to script one more variable – last item position + empty space (in px or cells / i dont know what is better).



    I writed before… i am not programmer, but this doing what i say (last item in right + 2 cells)



    var c = LL.getEvent().getContainer();


    var t = c.getBoundingBox();


    c.setPosition((t.getRight() – c.getWidth()) + (2*c.getCellWidth()) , (t.getBottom() – c.getHeight()) );



    Can you try please? and putt this my idea to your script? (Any way overwritten)

    ]]>

  12. Anonymous says:

    < ![CDATA[

    I think we are not understand each other.


    Your little script goes to one page more at the right, but you won’t find items there. (And believe me, move the items there is not as easy as you think)



    Ok, write as a list what you want the script to do after scrolling when in the right edge.



    For example, my actual script do:


    Wait until the screen is at the center of the one after the right most page.


    Move the camera without animation to the center of one before the left most page.


    Move the camera with animation to the left most page.

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Strange, your new version does not work now. (no infinity scrolling).

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Danbar Danbar don’t forget to check the free scroll!

    ]]>

  15. Anonymous says:

    < ![CDATA[

    TrianguloY  hehe, you have right 🙂



    This is much better! Very well working in portrait layout and panel in landscape layout.



    But if i have landscape layout and panel in landscape layout, not working good.



    Can you try set some desktop and panel to this:


    desktop (in portrait 6×6, in landscape 9×4) and panel (in portrait 6×1, in landscape 9×1). For panel set dual position.



    In portrait layout put to last page and last position some icon.


    In landscape layout change postion this icon to for example: 3 from left.


    If you have this and running your last script, our last icon have trouble…

    ]]>

  16. Anonymous says:

    < ![CDATA[

    Danbar Danbar thanks 🙂


    I can’t test now. You’ll need to wait. But my script is ‘theoretically’ perfect, so maybe the problem is the way the launcher send the data of the last item…I’ll check, but you’ll need to wait.

    ]]>

  17. Anonymous says:

    < ![CDATA[

    I’ll wait. I am glad that you work on it. I do not have that ability to do it yourself… 🙂

    ]]>

  18. Anonymous says:

    < ![CDATA[

    Danbar Danbar I tried it…but can’t see any problem. It works fine.


    Yes, I follow your rules.



    Can you explain it? (The problem I mean)



    Oh, keep in mind one thing. If it is scrolling automatically and you stop the scroll, it may not work as expected. Try to avoid this. (this is difficult to do, but can be done)

    ]]>

  19. Anonymous says:

    < ![CDATA[

    TrianguloY  http://www.nahraj-obrazek.cz/di-6139586203816.png  in this picture in top: my last page in panel (right side). (i go to this side and stop, nothing doing. After few second i go more right (my finger doing long tap and move left). I can go max to position visible on picture (bottom).



    I think that in landscape layout, the part of the script to the rotation starts too late.



    Sometime if my finger doing long tap and move left – icon  go back to his original postion.

    ]]>

  20. Anonymous says:

    < ![CDATA[

    Ooh, I understand now.


    But this is intended, because the script go to the pages, wherever the items are.


    If you want to start the ‘cycling’ with the item you need to uncheck the snap to pages, but then you will have the problem you had before.


    This is difficult to manage…can I ask why the item need to be in that position instead of in the last one?


    You have the dual position, so it is not because of portrait/landscape issues…

    ]]>

  21. Anonymous says:

    < ![CDATA[

    Hehe, my panel isnt originaly for me. I doing this panel as dockbar in theoretical example… 😉 (my and your work for other greenhorn users).



    yes, you have right with dual postion.



    Before i show you my script… i mean use this princip… if user are in last page… and doing long tap and move finger to left – start script for scroling if user is on last position of icon + 2 (or 3 or 4) * width cell (why width cell?  because user can set different grid for portrait and landcape layout – absolutly simply solution)

    ]]>

  22. Anonymous says:

    < ![CDATA[

    My script do exactly what you want, with pages. Do it with items can be done, but with lot’s of problems (what will happen if the item is at the left most cell of the last page? ) so I’m not going to modify it more. Sorry.


    This doesn’t mean I’m not going to help you, of course I will (whenever I could of course) but not with this.


    Sorry. I’m sure you will understand.

    ]]>

  23. Anonymous says:

    < ![CDATA[

    its ok, i understand.



    Most left items and more space i test in this script:


    var c = LL.getEvent().getContainer();


    var t = c.getBoundingBox();


    c.setPosition(t.getLeft() – (2*c.getCellWidth()) , (t.getBottom() – c.getHeight()) );



    (2* or 3* or 4* etc.) Its working…

    ]]>

  24. Anonymous says:

    < ![CDATA[

    Yesterday and today I tested your script.


    I found that would be enough to do this:



    In Script doing / 2 (divided by 2). Instead of a fixed number please add varriable.



    This variable should do:


    1) if phone is in landcape layout and panel is in landcape layout = use (divided by 1.5)



    2) if phone is in landcape layout and panel is in portrait layout = use (divided by 2)



    3) if phone is in portrait layout and panel is in landscape layout = use (divided by 2)



    4) if phone is in portrait layout and panel is in portrait layout = use (divided by 1.5)



    Can you please do this for me? It is the last-modification for this script ….


    in this week you writed me this:


    var d = LL.getCurrentDesktop();


    if(d.getHeight()>d.getWidth()){bla bla} maybe help this with condition.

    ]]>

  25. Anonymous says:

    < ![CDATA[

    var e = LL.getEvent();


    var c = e.getContainer();


    var box = c.getBoundingBox();


    var d = LL.getCurrentDesktop();


    if(c.getPositionScale()!=1)return;



    var margin = ( (d.getHeight()-d.getWidth() )*(c.getHeight()-c.getWidth() )>0 ? 2 : 1.5);


    var margin2 = margin/(margin-1);



    var pos = [c.getPositionX(),c.getPositionY()];


    var size = [c.getWidth(),c.getHeight()];


    var limits = [ [box.getRight(),box.getLeft()],[box.getBottom(),box.getTop()] ];



    var state = LL.getScriptTag() || “00”;


    state=[state[0],state[1]];



    var jump = [pos[0],pos[1]];


    var glide = [pos[0],pos[1]];



    for(var i=0;i< =1;++i){


    if (pos[i] > limits[i][0]-size[i]/margin ) {


    if(state[i]==”+”)return;


    jump[i] = limits[i][1]-size[i]/margin2;


    glide[i] = limits[i][1] ;


    state[i] = “-“;


    }else if (pos[i] < limits[i][1]-size[i]/margin2 ) {


    if(state[i]==”-“)return;


    jump[i] = limits[i][0]-size[i]/margin ;


    glide[i] = limits[i][0]-size[i] ;


    state[i]=”+”;


    } else {


    state[i] = “0”;


    }


    }



    LL.setScriptTag(state[0]+state[1]);




    if(state[0]!=”0″ || state[1]!=”0″){


    c.setPosition( jump[0] , jump[1], 1, false);


    c.setPosition( glide[0], glide[1], 1, true);


    }

    ]]>

  26. Anonymous says:

    < ![CDATA[

    thanks, i will testing with your last version.

    ]]>

  27. Anonymous says:

    < ![CDATA[

    I made a long-term test. You still need to add one condition. If there is only one screen, do nothing. (otherwise it scrolls the screen to same place, very strange)

    ]]>

  28. Anonymous says:

    < ![CDATA[

    Just replace



    if(c.getPositionScale()!=1)return;



    With




    if(c.getPositionScale()!=1 || (box.getRight()-box.getLeft()< =c.getWidth() && box.getBottom()-box.getTop()<=c.getHeight()))return;



    Test it, I can’t now

    ]]>

  29. Anonymous says:

    < ![CDATA[

    not working.

    ]]>

  30. Anonymous says:

    < ![CDATA[

    What is not working?

    ]]>

  31. Anonymous says:

    < ![CDATA[

    all script, not looping scrolling

    ]]>

  32. Anonymous says:

    < ![CDATA[

    Wait


    I see, there is a problem, if I make to not loop with only one page, it will scroll forever because you check the free scroll.

    ]]>

  33. Anonymous says:

    < ![CDATA[

    Danbar Danbar: I recommend you, well, I ask you to use Lukas Morawietz script. Check his latest posts.

    ]]>

  34. Anonymous says:

    < ![CDATA[

    yes, you have right, but if i set free scroll to no, looping still not working.

    ]]>

  35. Anonymous says:

    < ![CDATA[

    ok, i will try.

    ]]>

Leave a Reply

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