User Tools

Site Tools


script_animation_flip

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

====== About the script ====== * Purpose : These scripts will give you a beautiful page transition animation and a horizontal page loop * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] * Current Version : 1.0 ====== Changelog ====== * Version 1.0 (30/4/2014): initial release in wiki ====== How to use the script ====== * Set the main script to the positionchanged event of your container * 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 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! ====== Issues and hints ====== * this will break any other script, which uses item or container tags, and will be broken by them * with many items it won't run smooth * don't use dual position, this will do weird stuff //please report all bugs in the g+ community// ====== Main Script code ====== <code>var d=LL.getEvent().getContainer(); var cont=JSON.parse(d.getTag()||"null"); if(cont==null || !cont.setup) { return; } var dwidth=d.getWidth(); var pos=d.getPositionX(); var current=Math.floor(pos/dwidth); var pagepos=current*dwidth; var dposy=d.getPositionY(); var percent=(pos-pagepos)/dwidth; var items=d.getItems(); var l=items. getLength(); var tag=parseInt(LL.getScriptTag()); var maxpage= Math.floor((cont.max-dwidth)/dwidth); if((percent>0.005&&percent<99.995) && pos>cont.min-dwidth) { if(pos>cont.max-dwidth&&d.getProperties().getBoolean("noScrollLimit")) { d.setPosition(cont.min-dwidth ,dposy,1,false); } if(pos<cont.min) { cont.state=2; } for(i=0;i<l;i++) { item=items.getAt(i); var pinned= item.getProperties().getString("i.pinMode"); if(pinned=="NONE"|| pinned=="Y") { var data=JSON.parse(item.getTag()); if(data.page==current || (cont.state==2 && data.page==maxpage)) { if(percent<0.5) { item.setScale(1-percent*2,1); item.setPosition(pos+percent*(dwidth)+data.posx*(1-percent*2),data.posy); item.setVisibility(true); } else item.setVisibility(false); } if(data.page==current+1) { if(percent>=0.5) { item.setScale(percent*2-1,1); item.setPosition(pos+dwidth/2*(2-percent*2)+data.posx*(percent*2-1),data.posy); item.setVisibility(true); } else item.setVisibility(false); } } } } else { if(pos<cont.min) { d.setPosition(pos,dposy); d.setPosition(cont.max-dwidth,dposy,1,false); } cont.state=0; for(i=0;i<l;i++) { item=items.getAt(i); var data=JSON.parse(item.getTag()); item.setScale(1,1); item.setPosition(data.page*dwidth+data.posx,data.posy); item.setVisibility(true); } } </code> ====== Toggle Script code ====== <code>//config var main_scripts_name="AnimationFlip"; //endconfig var d=LL.getEvent().getContainer(); var box=d.getBoundingBox(); var cont=JSON.parse(d.getTag()||"null"); if(cont==null) cont=new Object(); cont.min=box.getLeft(); cont.max= box.getRight(); var items=d.getItems(); LL.runScript(main_scripts_name,null); var dwidth=d.getWidth(); if(cont.setup!=true) { for(x=0;x<items.length;x++) { var i=items. getAt(x); var posx=i.getPositionX(); var data=new Object(); data.page=Math.floor(posx/dwidth); data.posx=posx-data.page*dwidth; data.posy=i.getPositionY(); if(i.getProperties().getBoolean("i.onGrid")) { var cell=i.getCell(); data.left=cell.getLeft(); data.right=cell.getRight(); data.top=cell.getTop(); data.bottom=cell.getBottom(); } else data.left=null; i.setTag(JSON.stringify(data)); i.getProperties().edit().setBoolean("i.onGrid",false).commit(); } cont.setup=true; Android.makeNewToast("Animation enabled",true).show(); } else { for(x=0;x<items.length;x++) { var i=items. getAt(x); var data=JSON.parse(i.getTag()); if(data!=null && data.left!=null) { i.getProperties().edit().setBoolean("i.onGrid",true).commit(); i.setCell(parseInt(data.left), parseInt(data.top), parseInt(data.right), parseInt(data.bottom)); } } cont.setup=false; Android.makeNewToast("Animation disabled",true).show(); } d.setTag(JSON.stringify(cont)); </code>

script_animation_flip.1400322238.txt.gz · Last modified: 2014/05/17 10:23 by lm13