User Tools

Site Tools


script_animation_zigzag

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
script_animation_zigzag [2014/05/19 07:59]
lm13 [Toggle Script]
script_animation_zigzag [2014/09/24 16:11] (current)
lm13 [About the script]
Line 1: Line 1:
 ====== About the script ====== ====== About the script ======
-  * Purpose : These scripts ​will give you a beautiful page transition animation and an optional horizontal page loop+  * Purpose : This script ​will give you a beautiful page transition animation and an optional horizontal page loop
   * Author : [[https://​plus.google.com/​+LukasMorawietz|LM13]]   * Author : [[https://​plus.google.com/​+LukasMorawietz|LM13]]
   * Idea : TrianguloY   * Idea : TrianguloY
-  * Current Version : 1.0 +  * Current Version : 2.0 
-  * Link: ...+  * Link: https://​plus.google.com/​115366157037831519359/​posts/​TSNpAgUzhQQ 
 +  * Video : https://​plus.google.com/​115366157037831519359/​posts/​4Ktw58WRMji 
 +  * Download avialable! (Check repository)
  
 ====== Changelog ====== ====== Changelog ======
   * Version 1.0 (19/​5/​2014):​ initial release in wiki   * Version 1.0 (19/​5/​2014):​ initial release in wiki
 +  * Version 2.0 (21/​7/​2014):​ standalone, reworked structure
  
  
  
 ====== How to use the script ====== ====== 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+  * Set the 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   * 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+  * in this container: create a shortcut to the script
   * one click on the shortcut will enable the animation, clicking again will disable the animation. ​   * 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!   * BE SURE TO DISABLE THE ANIMATION BEFORE YOU EDIT, MOVE OR ADD ITEMS!
Line 20: Line 23:
 //please report all bugs in the g+ community!//​ //please report all bugs in the g+ community!//​
  
-====== ​Main Script ====== +====== Script ====== 
-<code>//​config+<sxh javascript;>//​config
 var bounciness=0.5;//​from 0 (normal) to 1 (bounce complete to top) var bounciness=0.5;//​from 0 (normal) to 1 (bounce complete to top)
 //endconfig //endconfig
  
  
-var d=LL.getEvent().getContainer();​+var e=LL.getEvent()
 +var d=e.getContainer();​
 var cont= JSON.parse(d.getTag()||"​null"​);​ var cont= JSON.parse(d.getTag()||"​null"​);​
-if(cont==null || !cont.setup || d.getPositionScale()!=1)return;​ 
 var dwidth=d.getWidth();​ var dwidth=d.getWidth();​
 var dheight=d.getHeight();​ var dheight=d.getHeight();​
 +var items=d.getItems();​
 +
 +
 +
 + 
 +if(e.getSource()!="​C_POSITION_CHANGED"​){
 +var items=d.getItems();​
 +var box=d.getBoundingBox();​
 +if(cont==null) cont=new Object(); cont.minx=box.getLeft();​ cont.maxx=box.getRight();​
 +var minpage=Math.floor(cont.minx/​dwidth);​
 +if(cont.setup!=true) ​
 +
 +cont.pages=[];​
 +for(x=0;​x<​Math.ceil(cont.maxx/​dwidth)-minpage;​x++)
 +{
 +cont.pages[x]=[];​
 +
 +for(x=0;​x<​items.length;​x++) ​
 +
 +var i=items.getAt(x); ​
 +var pinned=i.getProperties() .getString("​i.pinMode"​);​
 +if(pinned=="​NONE"​|| pinned=="​Y"​)
 +{
 +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();​
 +var p=Math.floor(data.posx/​dwidth)-minpage;​
 +cont.pages[p].push(i.getId());​
 +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.getLength();​x++) ​
 +
 +var i=items.getAt(x); ​
 +var data=JSON.parse(i.getTag());​
 +if(data!=null)
 +{
 +i.setPosition(data.posx,​data.posy);​
 +if(data.onGrid==true) ​
 +
 +iwidth=i.getWidth();​ iheight=i.getHeight();​ i.getProperties().edit().setBoolean("​i.onGrid",​true).commit(); ​
 +i.setCell(Math.round(data.posx/​cellw),​Math.round(data.posy/​cellh),​Math.round((data.posx+iwidth)/​cellw),​Math.round(( data.posy+iheight)/​cellh)); ​
 +
 +
 +
 +cont.setup=false;​ Android.makeNewToast("​Animation disabled",​true).show(); ​
 +
 +d.setTag(JSON.stringify(cont));​
 +}
 +
 +if(cont==null || !cont.setup || d.getPositionScale()!=1)return;​
 var dposx=d.getPositionX();​ var dposx=d.getPositionX();​
 var dposy=d.getPositionY();​ var dposy=d.getPositionY();​
Line 36: Line 95:
 var pagepos=current*dwidth;​ var pagepos=current*dwidth;​
 var percent=(dposx-pagepos)/​dwidth;​ var percent=(dposx-pagepos)/​dwidth;​
-var items=d.getItems();​ 
 var l=items.getLength();​ var l=items.getLength();​
 var maxpage=Math.floor( (cont.maxx-dwidth)/​dwidth);​ var maxpage=Math.floor( (cont.maxx-dwidth)/​dwidth);​
 +var minpage=Math.floor(cont.minx/​dwidth);​
  
 if((percent>​0.005 && percent<​99.995) && dposx>​cont.minx-dwidth) if((percent>​0.005 && percent<​99.995) && dposx>​cont.minx-dwidth)
Line 48: Line 107:
 if(dposx<​cont.minx&&​scrollLimit) if(dposx<​cont.minx&&​scrollLimit)
 cont.state=true;​ cont.state=true;​
-for(i=0;i<l;i++)+var items=cont.pages[(cont.state?​maxpage:​current)-minpage]; 
 +if(items!=null)
 { {
-item=items.getAt(i); +for(a=0;a<items.length;a++
-var pinned=item.getProperties() .getString("​i.pinMode"​);+
 +item=LL.getItemById(items[a]);
 var data=JSON.parse(item.getTag());​ 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);​ item.setPosition(pagepos+((data.posx%dwidth+dwidth)%dwidth),​data.posy-percent*dheight*bounciness);​
 } }
-if(Math.floor(data.posx/​dwidth) ==current+1)+
 +var items=cont.pages[current+1-minpage];​ 
 +if(items!=null)
 { {
 +for(a=0;​a<​items.length;​a++)
 +{
 +item=LL.getItemById(items[a]);​
 +var data=JSON.parse(item.getTag());​
 item.setPosition(data.posx,​data.posy-dheight*(1-percent)*bounciness);​ item.setPosition(data.posx,​data.posy-dheight*(1-percent)*bounciness);​
-} 
 } }
 } }
Line 71: Line 133:
 d.setPosition(dposx<​cont.minx?​cont.maxx-dwidth:​dposx,​dposy,​1,​false);​ d.setPosition(dposx<​cont.minx?​cont.maxx-dwidth:​dposx,​dposy,​1,​false);​
 cont.state=false;​ cont.state=false;​
-for(i=0;​i<​l;i++)+for(i=0;​i<​items.length;i++)
 { {
 item=items.getAt(i);​ item=items.getAt(i);​
Line 78: Line 140:
 } }
 } }
-</code> +</sxh>
- +
-====== 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>​ +
script_animation_zigzag.1400486383.txt.gz · Last modified: 2014/05/19 07:59 by lm13