====== Differences ====== This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
script_always_there_bar [2014/04/26 17:35] trianguloy |
script_always_there_bar [2018/08/14 16:50] (current) f43nd1r fix link |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| * 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. | * 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]] | * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] | ||
| - | * Link: https://plus.google.com/u/1/105066926163073195690/posts/DPufvGD2SjF (With video) | + | * Link: https://plus.google.com/+TrianguloY/posts/DPufvGD2SjF (With video) |
| ====== How to use the script ====== | ====== How to use the script ====== | ||
| Line 12: | Line 12: | ||
| * Set the script in the position change event of the desired container | * 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. | + | 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 ====== | ====== Script code ====== | ||
| - | <code> | + | <sxh javascript> |
| - | /*Settings */ | + | |
| //this number means the velocity of showing/hidding respectively | //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 ) | //1 is the default ( like the desktop ) the bigger, the faster (avoid negative numbers, between (0,1) will be slower ) | ||
| - | var vs = 1;//show | + | var vs = 2;//show |
| - | var vh = 1;//hide | + | 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 | ||
| Line 37: | Line 40: | ||
| //save | //save | ||
| */ | */ | ||
| - | var contpos = cont.getPositionY(); | + | var contpos = [cont.getPositionX(),cont.getPositionY()]; |
| - | var prev = parseInt(bar.getTag()); | + | var prev = JSON.parse(bar.getTag())||[0,0]; |
| - | var d = contpos-prev; | + | var d = [contpos[0]-prev[0],contpos[1]-prev[1]]; |
| - | bar.setTag(contpos); | + | bar.setTag(JSON.stringify(contpos)); |
| - | var barpos = bar.getPositionY(); | + | var barpos = [bar.getPositionX(),bar.getPositionY()]; |
| - | var size=bar.getScaleY() * bar.getHeight(); | + | var size = [-bar.getScaleX()*bar.getWidth(),-bar.getScaleY()*bar.getHeight()]; |
| - | var posx=bar.getPositionX(); | + | var sides = [horizontal,-vertical]; |
| + | var screen = [cont.getWidth(),cont.getHeight()]; | ||
| - | /*hide the bar */ | + | |
| - | if(d>0 && barpos>-size){ | + | for(var j=0;j<=1;++j){ |
| - | if(barpos-d*vh<-size || barpos<-size){ | + | |
| - | bar.setPosition(posx,-size); | + | if(sides[j]==0)continue; |
| - | }else{ | + | check=[0,size[j]]; |
| - | bar.setPosition(posx,barpos-d*vh); | + | 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); | ||
| + | } | ||
| } | } | ||
| - | /*show the bar */ | + | //down |
| - | if(d<0 && barpos<0){ | + | if(d[j]<0 && barpos[j]<check[0]){ |
| - | if(barpos-d*vs>0 || barpos>0){ | + | if(barpos[j]-d[j]*vs>check[0]){ |
| - | bar.setPosition(posx,0); | + | barpos[j]=check[0];//bar.setPosition(posx,0); |
| - | }else{ | + | }else{ |
| - | bar.setPosition(posx,barpos-d*vs); | + | barpos[j]=barpos[j]-d[j]*vs;//bar.setPosition(posx,barpos-d*vs); |
| - | } | + | |
| } | } | ||
| - | </code> | + | } |
| + | |||
| + | } | ||
| + | |||
| + | bar.setPosition(barpos[0],barpos[1]); | ||
| + | </sxh> | ||