User Tools

Site Tools


script_scrollbar

====== About the script ====== * Purpose : This script will allow you to set up a vertical Scrollbar for a desktop * Author : F43nd1r * Current Version : 1.1 * Link : https://plus.google.com/115366157037831519359/posts/AmyQ3J8PUyc * //Deprecated// ====== Changelog ====== * Version 1.0 (1/4/2014): initial release in wiki * Version 1.1 (2/6/2014): added tap ====== How to use the script ====== * create a panel where you want to scroll, pin it and give it a label * enable infinite scrolling in the panel * put in the panel on (0,0) an item, give it a nice icon and disable it (set to not clickable) * set the script to both desktops and panels positionchanged event and to panels tap-on-empty-space event * set up your configuration at the beginning of the script ====== Issues and hints ====== * on startup the position in the scrollbar may be incorrect //please report all bugs in the g+ community// ====== Script code ====== <sxh javascript;>//config var Desktop_Name="Scrollbar"; var Panel_Name="Scroll"; var Indicator_Name="Indicator"; var scroll_to_pages=false; //endconfig var e=LL.getEvent(); var d=LL.getDesktopByName(Desktop_Name); var c=d.getItemByLabel(Panel_Name).getContainer(); var item =c.getItemByLabel(Indicator_Name); if(e.getSource()=="C_CLICK")c.setPosition(0,-e.getTouchScreenY()+item.getHeight()/2,1,false); var cheight=c.getHeight(); var cpos=c.getPositionY(); var iheight=item.getHeight(); var dpos=d.getPositionY(); var dheight=d.getHeight(); if(cpos>0) c.setPosition(0,0,1,false); if(cpos<iheight-cheight) c.setPosition(0,iheight-cheight,1,false); var bounds=d.getBoundingBox(); var min=bounds.getTop()/dheight; var max=bounds.getBottom()/dheight-1; var pmax=cheight-iheight; var dcount=max-min; if(e.getContainer()==c) { var goto=min-(cpos/pmax*dcount); if(scroll_to_pages)goto=Math.round(goto); if(goto<min)goto=min; if(goto>max)goto=max; d.setPosition(0,goto*dheight,1,false); } else { var current=dpos/dheight; c.setPosition(0,-pmax*((current-min)/dcount),1,false); } </sxh>

script_scrollbar.txt · Last modified: 2016/06/28 12:14 by f43nd1r