User Tools

Site Tools


script_zoom_scrolling

====== About the script ====== * Purpose : This script will place the items in an infinite looping row, so the camera movement is as smooth as possible. The items won't overlap, you can click them. * Author : [[https://plus.google.com/+TrianguloY|TrianguloY]] * Link: https://plus.google.com/+TrianguloY/posts/bV4rN8sNjQK (with video) ====== How to use the script ====== [Please note: I made the script time ago, and maybe it don't work now as expected. If so tell me in the link abobe] Instructions: * copy paste this script and set it at the position change event of a container (it will use all the items inside, so better a panel) * the items will need to be not pinned and detached from the grid. * Set the scrolling to free scroll. It automatically adapts if a new item is added or removed. However you will need to scroll one loop to update. Settings: change them as you want * maxsize: the maximum size the items will have * see: the number of items you will be able to see at once ====== Script code ====== <sxh javascript> /*Config */ var see = 5;// items you will see var maxsize = 2; //Max scale of the item var desk = LL.getEvent().getContainer(); var v = desk.getHeight()/2; var h = desk.getWidth()/2; var pos = desk.getPositionX(); if(h==0)return; var items = desk.getItems(); var n = items.getLength() var distance = 2*h/see; for(var i=0;i<n;++i){ var p = Math.floor(pos/distance-n/2 +1); var arg = (p+i)%n; while(arg<0)arg+=n; var item; try{ item = items.getAt(arg); }catch(e){alert("Error: arg="+arg+" p="+p+" pos="+pos+" distance="+distance+" h="+h);return;} var size = pos-(p+i)*distance ; if(size<0)size=-size; size=maxsize-( size /h*maxsize ); if(size<0.1){ size =0.1; } item.setSize(distance/maxsize,2*v); item.setScale(size,size); item.setPosition( h+(p+i) *distance -distance/maxsize/2*size ,v-v*size); /*items.getAt(arg).setLabel(items.getAt(arg).getWidth() ); */ } </sxh>

script_zoom_scrolling.txt · Last modified: 2018/08/14 16:58 by f43nd1r