User Tools

Site Tools


script_always_there_bar

====== About the script ====== * Purpose : This is a script that place an item (in the video a panel) always on top of the screen. Scroll down the desktop to show it. Scroll up to hide. * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/+TrianguloY/posts/DPufvGD2SjF (With video) ====== How to use the script ====== Instructions: * Copy paste this script as a new one. * IMPORTANT: you need to label "always-bar" the item you want to move * Pin that item and detach it from the screen * Set the script in the position change event of the desired container Settings: * you can change the velocity the item is scrolled. Just change the numbers of the first part of the script, nothing more. * NEW : you can specify the direction of scrolling vertically and horizontally. Change the parameter in the config (you can have vertical and horizontal simultaneously) ====== Script code ====== <sxh javascript> //this number means the velocity of showing/hidding respectively //1 is the default ( like the desktop ) the bigger, the faster (avoid negative numbers, between (0,1) will be slower ) var vs = 2;//show var vh = 0.5;//hide //this will set the direction var vertical = 1;//-1,0,1 bottom,disable,top var horizontal = 0; //-1,0,1 left,disable,right var cont = LL.getEvent().getContainer(); //item to move var bar = cont.getItemByLabel("always-bar"); if(bar==null){alert("Warning: no item with label 'always-bar' found.");return;} /* current position // in case don't exist //difference //save */ var contpos = [cont.getPositionX(),cont.getPositionY()]; var prev = JSON.parse(bar.getTag())||[0,0]; var d = [contpos[0]-prev[0],contpos[1]-prev[1]]; bar.setTag(JSON.stringify(contpos)); var barpos = [bar.getPositionX(),bar.getPositionY()]; var size = [-bar.getScaleX()*bar.getWidth(),-bar.getScaleY()*bar.getHeight()]; var sides = [horizontal,-vertical]; var screen = [cont.getWidth(),cont.getHeight()]; for(var j=0;j<=1;++j){ if(sides[j]==0)continue; check=[0,size[j]]; if(sides[j]==1)check=[check[0]+screen[j],check[1]+screen[j]]; //up if(d[j]>0 && barpos[j]>check[1]){ if(barpos[j]-d[j]*vh<check[1]){ barpos[j]=check[1];//bar.setPosition(posx,-size); }else{ barpos[j]=barpos[j]-d[j]*vh;//bar.setPosition(posx,barpos-d*vh); } } //down if(d[j]<0 && barpos[j]<check[0]){ if(barpos[j]-d[j]*vs>check[0]){ barpos[j]=check[0];//bar.setPosition(posx,0); }else{ barpos[j]=barpos[j]-d[j]*vs;//bar.setPosition(posx,barpos-d*vs); } } } bar.setPosition(barpos[0],barpos[1]); </sxh>

script_always_there_bar.txt · Last modified: 2018/08/14 16:50 by f43nd1r