User Tools

Site Tools


script_scrollbar_interactive

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

====== About script ====== * Purpose : Scrollbar to show screen position in container. Also click on scrollbar to go scroll to that position * Author : TBog * Link: ... ====== How to use the script ====== - Create a panel with the label **scrollBar** - Inside the panel place an item, detached from grid and not clickable. Disable label and icon. Set background color. This will be the page indicator. - Set **onScrollBarTap** script as on tap empty space event of panel - Set **updateScrollBar** to the change position event of the container that holds the **scrollBar** panel ... ====== Script code ====== updateScrollBar <code> var c = LL.getEvent().getContainer(); var bgC = c.getItemByLabel("scrollBar").getContainer(); var fg = bgC.getItems().getAt(0); var bgW = bgC.getWidth(); var bgH = bgC.getHeight(); var bb = c.getBoundingBox(); var wholeW = bb.getRight() - bb.getLeft(); var wholeH = bb.getBottom() - bb.getTop(); var fgW = Math.min(1, c.getWidth() / wholeW) * bgW; var fgH = Math.min(1, c.getHeight() / wholeH) * bgH; var fgX = bgW * (c.getPositionX() - bb.getLeft()) / wholeW; var fgY = bgH * (c.getPositionY() - bb.getTop()) / wholeH; bgC.setPosition(0, 0, 1, false); fg.setScale(1, 1); fg.setSize(fgW, fgH); fg.setPosition(fgX, fgY); </code> onScrollbarTap <code> var bSnapPage = false; var bSnapGrid = true; var e = LL.getEvent(); var ey= e.getTouchY(); var ex= e.getTouchX(); var ec= e.getContainer(); var itm = ec.getOpener(); var c = itm.getParent(); var w = c.getWidth(); var h = c.getHeight(); var bb= c.getBoundingBox(); var wholeW = bb.getRight() - bb.getLeft(); var wholeH = bb.getBottom() - bb.getTop(); var pPW = w / wholeW; var pPH = h / wholeH; var pX = ex / ec.getWidth(); var pY = ey / ec.getHeight(); if ( bSnapPage ) { pX-= pX % pPW; pY-= pY % pPH; } else { pX-= pPW * 0.5; pY-= pPH * 0.5; } if ( bSnapGrid ) { var pGW = c.getCellWidth() / wholeW; var pGH = c.getCellHeight() / wholeH; pX-= pX % pGW; pY-= pY % pGH; } pX = Math.min(1 - pPW, Math.max(0, pX)); pY = Math.min(1 - pPH, Math.max(0, pY)); LL.goToDesktopPosition(c.getId(), pX * wholeW + bb.getLeft(), pY * wholeH + bb.getTop()); </code> TODO: Script to setup more easily

script_scrollbar_interactive.1399124187.txt.gz · Last modified: 2014/05/03 13:36 by tbog