Horizontal and vertical screen loop with items movement

Horizontal and vertical screen loop with items movement

– allow infinite scroll (decelerate/bounce may also work instead)

– set script in positionchanged event of your desktop. (should work also in other containers)

– i recommend to use snap to pages, it may fail without

– set up your configuration: if you want to disable it for one direction set the value to false

Known bugs:

Scrolling left very fast with a low amount of pages moves items to false positions (Too far left). fixed

– Scrolling right/bottom fast moves items to false positions (Too far right/bottom). occurence reduced

using the script in more than one container is buggy fixed

no check for single pages added

——————————

//config

var horizontalScrolling=true;

var verticalScrolling=true;

//endconfig

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

if(d.getId()==-1)d=LL.getCurrentDesktop();

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

var data=JSON.parse(d.getTag()||”null”);

if (data==null)

{

data=new Object();

data.stateX=0;

data.stateY=0;

data.running=false;

}

if(data.running==true)return;

data.running=true;

d.setTag(JSON.stringify(data));

var dwidth=d.getWidth();

var dheight=d.getHeight();

var cwidth=d.getCellWidth();

var cheight=d.getCellHeight();

var posX=d.getPositionX();

var posY=d.getPositionY();

var box=d.getBoundingBox();

var minX=box.getLeft();

var maxX=box.getRight();

var minY=box.getTop();

var maxY=box.getBottom();

var fullwidth=maxX-minX;

var fullheight=maxY-minY;

var items=d.getItems();

var setLeft=function()

{

data.stateX=1;

for(x=0;x

{

var item=items.getAt(x);

if(item.getPositionX()>=maxX-dwidth)

{

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

{

var cell=item.getCell();

item.setCell(Math.round(cell.getLeft()-fullwidth/cwidth), Math.round(cell.getTop()), Math.round(cell.getRight() -fullwidth/cwidth), Math.round(cell.getBottom()));

}

else

{

item.setPosition(item.getPositionX()-fullwidth,item.getPositionY());

}

}

}

}

var setRight=function()

{

data.stateX=0;

for(x=0;x

{

var item=items.getAt(x);

if(item.getPositionX()

{

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

{

var cell=item.getCell();

item.setCell( Math.round(cell.getLeft()+fullwidth/cwidth), Math.round(cell.getTop()), Math.round(cell.getRight() +fullwidth/cwidth), Math.round(cell.getBottom()));

}

else

{

item.setPosition(item.getPositionX()+fullwidth,item.getPositionY());

}

}

}

}

var setTop=function()

{

data.stateY=1;

for(x=0;x

{

var item=items.getAt(x);

if(item.getPositionY()>=maxY-dheight)

{

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

{

var cell=item.getCell();

item.setCell(Math.round(cell.getLeft()), Math.round(cell.getTop()-fullheight/cheight), Math.round(cell.getRight()), Math.round(cell.getBottom()-fullheight/cheight));

}

else

{

item.setPosition(item.getPositionX(),item.getPositionY()-fullheight);

}

}

}

}

var setBottom=function()

{

data.stateY=0;

for(x=0;x

{

var item=items.getAt(x);

if(item.getPositionY()

{

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

{

var cell=item.getCell();

item.setCell( Math.round(cell.getLeft()), Math.round(cell.getTop()+fullheight/cheight), Math.round(cell.getRight()), Math.round(cell.getBottom()+fullheight/cheight));

}

else

{

item.setPosition(item.getPositionX(),item.getPositionY()+fullheight);

}

}

}

}

if(fullwidth>dwidth && horizontalScrolling)

{

if(data.stateX==1)

{

if(posX<=minX || posX>=minX+dwidth)

{

if(posX<=minX)

d.setPosition(maxX,posY,1,false);

setRight();

}

}

else

{

if(posX

setLeft();

if(posX>maxX-dwidth)

{

d.setPosition(minX-dwidth,posY,1,false);

setLeft();

}

}

}

else

{

if(posX

d.setPosition(minX,posY,1,false);

if(posX>maxX-dwidth)

d.setPosition(maxX-dwidth,posY,1,false);

}

posX=d.getPositionX();

if(fullheight>dheight && verticalScrolling)

{

if(data.stateY==1)

{

if(posY<=minY || posY>=minY+dheight)

{

if(posY<=minY)

d.setPosition(posX,maxY,1,false);

setBottom();

}

}

else

{

if(posY

setTop();

if(posY>maxY-dheight)

{

d.setPosition(posX,minY-dheight,1,false);

setTop();

}

}

}

else

{

if(posY

d.setPosition(posX,minY,1,false);

if(posY>maxY-dheight)

d.setPosition(posX,maxY-dheight,1,false);

}

var done=function()

{

data.running=false;

d.setTag(JSON.stringify(data));

}

setTimeout(done,0);

Please report all bugs!

*And give feedback*

]]>

45 Commentsto Horizontal and vertical screen loop with items movement

  1. Anonymous says:

    < ![CDATA[

    cool.


    Can be improved (vertical? difficult I know), but it is very good as it is.



    Just 3 things:



    d.getId!=-1 easier than convert it to string



    When computing the cell positions, use Math.round( ## ) because the float operations can ( and do) strange things.



    In setPosition, use d.getPositionY() for the Y position, don’t reset it to 0



    😉

    ]]>

  2. Anonymous says:

    < ![CDATA[

    TrianguloY OK, I’ll realize your easy changes and think of vertical too.



    Edit: changes done.



    If you want only vertical scrolling, it would be easy, but both… 

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Can someone help me with the fast scrolling bug? It only occurs when scrolling very fast, and I just can’t figure out why the items are moved false :'(

    ]]>

  4. Anonymous says:

    < ![CDATA[

    – updated: bugfix (using container.settag) –

    ]]>

  5. Anonymous says:

    < ![CDATA[

    – updated: added vertical scrolling –



    TrianguloY it was easier than I thougt. Mainly it was copy&paste. You can even scroll diagonal, so all four edges come together!

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Very good! A little question, item seem flash when it is from first page jump to last page. Others work smooth. Great job!

    ]]>

  7. Anonymous says:

    < ![CDATA[

    hon keung chung yes sorry, this appears at the point items and the desktop are moved at the same time. This cannot be resolved ATM, because items can not be displayed at two positions at the same time and it needs some time to move them around. Also double caching the screen graphics isn’t implemented yet…

    ]]>

  8. Anonymous says:

    < ![CDATA[

    I testing your script.



    1) bug: if user have only one screen on desktop (not have for example screen on left or right side), your script doing looping from first screen to first screen after swipe left or right.



    2) if user doing double tap for zoom in/out and again repeat double tap for normal size, now is not on home screen.

    ]]>

  9. Anonymous says:

    < ![CDATA[

    1) use scrolling direction: auto



    Both: I’ll check soon.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    2) is working for me. Could you share the desktop or explain surroundings?


    Or just try again on a new desktop.

    ]]>

  11. Anonymous says:

    < ![CDATA[

    1) mistake – i mean only as example. Same problem have left/right or top/bottom. I mean – you must add condition: if only one screen, do nothing (not move).

    ]]>

  12. Anonymous says:

    < ![CDATA[

    If you set scrolling direction to auto you can’t scroll if only one page…


    But I’ll add a check.

    ]]>

  13. Anonymous says:

    < ![CDATA[

    ups, myblame, i dont have enabled no scroll limit… probapbly working both

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Check again and Come back 😉


    But with 1) you were right… It was a bug.



    —————


    Update


    (see first post)

    ]]>

  15. Anonymous says:

    < ![CDATA[

    update


    Forgot to handle two cases 😣

    ]]>

  16. Anonymous says:

    < ![CDATA[

    ok, i will try and test.

    ]]>

  17. Anonymous says:

    < ![CDATA[

    BTW: ty for give it a try 😊

    ]]>

  18. Anonymous says:

    < ![CDATA[

    strange thing 



    I do not know whether it makes itself LLX or your script … 



    I have icons on the home screen (with the house icon in edit mode) and then some on the left and the right. (Three screens on one desktop or panel).



    In the beginning, everything is fine, the script works well. 



    Trying to perform zoom in / out (by double tap) again and zoom in / out. Many time. And scroll the screen (left / right side). Sometimes also turn around with the phone (from portrait to landscape layout). And this is all combined. 



    But then something happens. Suddenly after zoom in / out icons I have by themselves outside of the home screen (usually move on two screens right). Thus the move all the icons, including pinned icons. Pinned Icon then not visible (because they are outside the main / home screen). Well the problem is then visible in edit mode. 



    It makes desktop, also panel.

    ]]>

  19. Anonymous says:

    < ![CDATA[

    OK, thank you for feedback, I’ll try to reproduce the bug after school, so I can fix it.

    ]]>

  20. Anonymous says:

    < ![CDATA[

    I’m sorry. I didn’t managed to find out when the bug occurs. Zooming works for me all the time.

    ]]>

  21. Anonymous says:

    < ![CDATA[

    Are you using the dual position option?

    ]]>

  22. Anonymous says:

    < ![CDATA[

    Yes

    ]]>

  23. Anonymous says:

    < ![CDATA[

    You must try more and more time.

    ]]>

  24. Anonymous says:

    < ![CDATA[

    Sorry, this is caused by the dual position, whhich I can’t access ATM.


    I’ll try around a bit, but I can’t give an absloute fix.

    ]]>

  25. Anonymous says:

    < ![CDATA[

    Can doing Pierre in LL? Is it bug?

    ]]>

  26. Anonymous says:

    < ![CDATA[

    No, its not a bug, it’s a missing feature, we just cant get the other position… e.g if its in landscape, we can’t get the portrait setting

    ]]>

  27. Anonymous says:

    < ![CDATA[

    Ok, can you write this needed things to feature suggestion? For Pierre know that we need this function…

    ]]>

  28. Anonymous says:

    < ![CDATA[

    OK.



    This bug is a really complex bug. I would have to write a script for switching orientation too.


    Is this really a serious problem?

    ]]>

  29. Anonymous says:

    < ![CDATA[

    For me no (i know what i must doing). But for greenhorn users LL will be. Big problems have pinned items because after this bug are not vissible.

    ]]>

  30. Anonymous says:

    < ![CDATA[

    Due to android limitation It’s nearly impossible to resolve this

    ]]>

  31. Anonymous says:

    < ![CDATA[

    I’ve had some other ideas how to resolve all these bugs with items moved false, but first I need to access the screen orientation…

    ]]>

  32. Anonymous says:

    < ![CDATA[

    I understand well that Pierre must first make new function in script editor  ( something() )?

    ]]>

  33. Anonymous says:

    < ![CDATA[

    Yes. I’ll first try to make a version of this script, which won’t work with dual position, that’s too complex ATM

    ]]>

  34. Anonymous says:

    < ![CDATA[

    Pierre Hébert  Can you give us some help in that? (several of my responses above this text …)

    ]]>

  35. Anonymous says:

    < ![CDATA[

    I will try to have a look at this, but probably not before the middle of the next week because I am very busy at the moment. I saved the link to this post so I will remember it.

    ]]>

  36. Anonymous says:

    < ![CDATA[

    Pierre Hébert I don’t mind how long you put it aside 😉



    I have discovered, that one problem is:


    – the items from the most right are moved to most left by script.


    – the next execution of the script asks for the bounding box, LL returns the old bounding box with items on right.


    That’s why I need to know when these movements finished

    ]]>

  37. Anonymous says:

    < ![CDATA[

    update: bugfix



    Danbar Danbar please check if your bug still occurs.

    ]]>

  38. Anonymous says:

    < ![CDATA[

    Ok, i will test in the evening. I have a discharged battery in the phone and charging cable I have at home…

    ]]>

  39. Anonymous says:

    < ![CDATA[

    OK, I have time

    ]]>

  40. Anonymous says:

    < ![CDATA[

    dual position – not working (I assume that this is a temporary solution.)



    1) You can integrate these improvements?


    https://plus.google.com/106262825040060073183/posts/Jfd8xfrEFKQ (ansfer from TrianguloY – his script)


    – user can go to select position by tap to specific position, if tap to back key – user is on home position.



    2) after double tap… are vissible all items (small). User can scroll to side – is it possible doing infinity scrolling in this mode too?



    Otherwise, I think that the script works well.

    ]]>

  41. Anonymous says:

    < ![CDATA[

    1) this wouldn’t make sense to be integrated, because it’s called by a different event, but you can use both scripts parallel, they won’t interfere.



    2) I think this might look stupid, because the bounding box is normally displayed smaller than the display is, but if you want infinite scrolling in this mode, remove the line if(d.getPositionScale()!=1)return;


    and replace in every d.setposition the 1 with a d.getpositionscale()


    (untested)

    ]]>

  42. Anonymous says:

    < ![CDATA[

    2) I tried: not working, forget it.

    ]]>

  43. Anonymous says:

    < ![CDATA[

    Regarding the dual position: I didn’t changed anything, what could interfere with dual position, so it shouldn’t be more bad than before

    ]]>

  44. Anonymous says:

    < ![CDATA[

    dual position.. i use your script in panel. In portrait layout i have added as penultimate place chrome, and last position opera. In landscape layout I wanted to set conversely. But if i change in landcape layout, now i have same change in portrait layout.

    ]]>

  45. Anonymous says:

    < ![CDATA[

    I have set your script in positionchanged.


    Second script (from point 1) i set to single tap. (both in panel). this combination I highly recommend it.

    ]]>

Leave a Reply

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