**This is an old revision of the document!** ----
====== About the script ====== * Purpose : These scripts will give you a beautiful page transition animation and an optional horizontal page loop * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] * Idea : TrianguloY * Current Version : 1.0 * Link: ... ====== Changelog ====== * Version 1.0 (19/5/2014): initial release in wiki ====== How to use the script ====== * Set the main script to the positionchanged event of your container; configure the main script, if you want another bounciness * enable infinte scrolling if you want a page loop, disable it if you don't want to loop through pages * in this container: create a shortcut to the [[script_toggle_animation|Toggle Script]] and set up toggle sripts configuration * one click on the shortcut will enable the animation, clicking again will disable the animation. * BE SURE TO DISABLE THE ANIMATION BEFORE YOU EDIT, MOVE OR ADD ITEMS! //please report all bugs in the g+ community!// ====== Main Script ====== <code>//config var bounciness=0.5;//from 0 (normal) to 1 (bounce complete to top) //endconfig var d=LL.getEvent().getContainer(); var cont= JSON.parse(d.getTag()||"null"); if(cont==null || !cont.setup || d.getPositionScale()!=1)return; var dwidth=d.getWidth(); var dheight=d.getHeight(); var dposx=d.getPositionX(); var dposy=d.getPositionY(); var current=Math.floor(dposx/dwidth); var pagepos=current*dwidth; var percent=(dposx-pagepos)/dwidth; var items=d.getItems(); var l=items.getLength(); var maxpage=Math.floor( (cont.maxx-dwidth)/dwidth); if((percent>0.005 && percent<99.995) && dposx>cont.minx-dwidth) { var scrollLimit=d.getProperties() .getBoolean("noScrollLimit"); if(dposx>cont.maxx-dwidth&&scrollLimit){ d.setPosition(cont.minx-dwidth,dposy,1,false); } if(dposx<cont.minx&&scrollLimit) cont.state=true; for(i=0;i<l;i++) { item=items.getAt(i); var pinned=item.getProperties() .getString("i.pinMode"); var data=JSON.parse(item.getTag()); if(pinned=="NONE"|| pinned=="Y") { if(Math.floor(data.posx/dwidth)==current||(cont.state && Math.floor(data.posx/dwidth)==maxpage)) { item.setPosition(pagepos+((data.posx%dwidth+dwidth)%dwidth),data.posy-percent*dheight*bounciness); } if(Math.floor(data.posx/dwidth) ==current+1) { item.setPosition(data.posx,data.posy-dheight*(1-percent)*bounciness); } } } } else { d.setPosition(dposx,dposy); d.setPosition(dposx<cont.minx?cont.maxx-dwidth:dposx,dposy,1,false); cont.state=false; for(i=0;i<l;i++) { item=items.getAt(i); var data=JSON.parse(item.getTag()); item.setPosition(data.posx,data.posy); } } </code> ====== Toggle Script ====== <code>//config var mainScriptsName= "AnimationDiagonal"; //endconfig var d=LL.getEvent().getContainer(); var box=d.getBoundingBox(); var cont=JSON.parse(d.getTag()||"null"); if(cont==null) cont=new Object(); cont.minx=box.getLeft(); cont.maxx=box.getRight(); cont.miny=box.getTop(); cont.maxy=box.getBottom(); var items=d.getItems(); LL.runScript(mainScriptsName,null); var dwidth=d.getWidth(); var dheight=d.getHeight(); if(cont.setup!=true) { for(x=0;x<items.length;x++) { var i=items.getAt(x); var data=new Object(); data.posx=i.getPositionX(); data.posy=i.getPositionY(); if(i.getProperties().getBoolean("i.onGrid")) data.onGrid=true; else data.onGrid=false; i.getProperties().edit().setBoolean("i.onGrid",false).commit(); i.setTag(JSON.stringify(data)); } cont.setup=true; Android.makeNewToast("Animation enabled",true).show(); } else { var cellw=d.getCellWidth(); var cellh=d.getCellHeight(); for(x=0;x<items.length;x++) { var i=items.getAt(x); var data=JSON.parse(i.getTag()); if(data!=null && data.onGrid==true) { i.getProperties().edit().setBoolean("i.onGrid",true).commit(); i.setCell(Math.round(data.posx/cellw),Math.round(data.posy/cellh),Math.round((data.posx+i.getWidth())/cellw),Math.round(( data.posy+i.getHeight())/cellh)); } i.setVisibility(true); } cont.setup=false; Android.makeNewToast("Animation disabled",true).show(); } d.setTag(JSON.stringify(cont)); </code>