Always-there bar

Always-there bar

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.

Pierre Hébert: you did it.

I’m not sure how, but with the synchronous scripts…all is beautiful 😀 Thanks!

Luckily I made a demonstration video with the 9.9.9 version. Another one with 9.9.10

I’m sure you will find the difference 😉 The change is awesome!

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 grid

– Set the script in the position change event of the desktop

Settings: you can change the velocity of scrolling. Just modify the numbers at the beggining of the script, nothing more

———————————

/*Settings */

//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

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.getPositionY();

var prev = parseInt(bar.getTag());

var d = contpos-prev;

bar.setTag(contpos);

var barpos = bar.getPositionY();

var size=bar.getScaleY() * bar.getHeight();

var posx=bar.getPositionX();

/*hide the bar */

if(d>0 && barpos>-size){

if(barpos-d*vh<-size || barpos<-size){

bar.setPosition(posx,-size);

}else{

bar.setPosition(posx,barpos-d*vh);

}

}

/*show the bar */

if(d<0 && barpos<0){

if(barpos-d*vs>0 || barpos>0){

bar.setPosition(posx,0);

}else{

bar.setPosition(posx,barpos-d*vs);

}

}

]]>
« (Previous Post)

39 Commentsto Always-there bar

  1. Anonymous says:

    < ![CDATA[

    How do you find all these ideas ?


    Well done !

    ]]>

  2. Anonymous says:

    < ![CDATA[

    By the way, how does it behaves on your device ? Is v9.9.10 smoother than the previous version ? (difficult to see on the video)

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Yes it is. Very smooth. As much as the default desktop scrolling!

    ]]>

  4. Anonymous says:

    < ![CDATA[

    TrianguloY I try not to ask people to be my “tech”, but I’m having troubles implementing this and was wondering if you could help.



    LLX 10..0.1



    First off, I don’t see a “scroll event” for the desktop, so I am trying to set it on the swipe down event. Let me know if this is wrong. What am I missing?



    I created a panel and pinned it to the top of my home screen.



    I copy/pasted the script as presented and when I had the issue the first time, I retyped it manually and stripped out the comments.



    When I try to swipe down, I get the following:



    At line 3: missing ) after argument list (BarAlwaysOnTop#3)




    I have the getItemByID set to 02000b (the Item# I found in the hierarchical list to match my panel – but I don’t know if it’s even parsing that far.



    Any help you can provide would be great. Let me know if you need any more info from me. Thanks in advance. (P.S. I’m not too good with scripting, but I am a server/application IT guy and can follow directions, so you don’t have to feel like you’re talking to a complete techno noob). 🙂

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Jacob Nyhart don’t worry, glad to hear someone is using my script 🙂


    Ok, two things:


    The scroll event I mean is the ‘position change’ under events and actions, I’ll update it, thanks.


    And for the panel Id, you can use the one from the hierarchy menu, but it is in hexadecimal so you need to add ‘0x’ as prefix (zero, and ex)


    0x02000b in your case



    Any other question, please ask 🙂

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Thanks TrianguloY !  OK – it was no longer giving me any error messages, but it was also was not showing/hiding the panel. The panel was just pinned to the top of my screen. I resolved this by detaching the panel from the grid – which is what I think needed to happen?!? In any respect, I love the script and the idea. Thanks!

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Jacob Nyhart exactly. Didn’t I mentioned it? Ops.


    Thanks 🙂

    ]]>

  8. Anonymous says:

    < ![CDATA[

    TrianguloY Hey, no worries. That’s why this community is so great – peer review to help create the best customizations! I appreciate your help and great scripts. It’s helping me learn a lot about how the scripting works in LL(x).

    ]]>

  9. Anonymous says:

    < ![CDATA[

    samson olanrewaju I prefer to help you here, instead of in the video.


    What problem do you have? Just explain. I’ll do my best.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    I can’t implement this script. It’s giving me headache

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Do you have an error? Is it just don’t working? Don’t you know how to set it?


    Don’t worry, if this is your first time with scripts I’ll try to explain as detailed as possible. If so say it.

    ]]>

  12. Anonymous says:

    < ![CDATA[

    It’s my first time..can you explain the process one after the other. In a simplified manner. TrianguloY

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Ok, let’s see.


    First of all. You need to copy the script, and paste it in the script editor. It’s an app that need to be in your app drawer, if you can’t see it try to refresh (the three dots menu, refresh)


    Once you are there click ‘new’ and paste the script there. Remember the name (you can change it long pressing the name)

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Thank you. I have copied the script. And placed in in the script editor. This is what i copied …i changed the name.



    /*Settings */


    //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 = 1;//show


    var vh = 1;//hide







    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.getPositionY();


    var prev = parseInt(bar.getTag());


    var d = contpos-prev;


    bar.setTag(contpos);




    var barpos = bar.getPositionY();


    var size=bar.getScaleY() * bar.getHeight();


    var posx=bar.getPositionX();



    /*hide the bar */


    if(d>0 && barpos>-size){


    if(barpos-d*vh< -size || barpos<-size){


    bar.setPosition(posx,-size);


    }else{


    bar.setPosition(posx,barpos-d*vh);


    }


    }



    /*show the bar */


    if(d<0 && barpos<0){


    if(barpos-d*vs>0 || barpos>0){


    bar.setPosition(posx,0);


    }else{


    bar.setPosition(posx,barpos-d*vs);


    }


    }

    ]]>

  15. Anonymous says:

    < ![CDATA[

    Second step: rename the item you want to move as ‘always-bar’


    to do so just long click the item and change the label


    If it is a panel, you need to enter edit mode and then long click the panel, the label option is in the settings under the ‘+’ tab



    EDIT:


    Oh, I almost forget.


    You need to detach the panel from the grid.


    Go to edit mode


    Long click the panel


    Position


    Detach from grid

    ]]>

  16. Anonymous says:

    < ![CDATA[

    Oh, don’t forget to pin the item too (in their settings in the ‘+’ tab set the pinned state to horizontal and vertical)



    The last step is perhaps the most difficult.


    You need to long click the background of the desktop, where the panel is. A pop-up will appear, click in ‘lightning settings’ ‘current desktop’


    Then click in ‘events and actions’


    Click ‘position changed’, the script editor will appear.


    If the script that is there is this one, just press back on the phone. If not select it in the list and then press back.



    You will be in the desktop now, scroll to see if it works. Any problem just ask. :)

    ]]>

  17. Anonymous says:

    < ![CDATA[

    Done.. I have changed the panel name

    ]]>

  18. Anonymous says:

    < ![CDATA[

    It’s not working

    ]]>

  19. Anonymous says:

    < ![CDATA[

    Oh, I almost forget.


    You need to detach the panel from the grid.


    Go to edit mode


    Long click the panel


    Position


    Detach from grid

    ]]>

  20. Anonymous says:

    < ![CDATA[

    What am I doing wrong. I have followed your explanation to the letter

    ]]>

  21. Anonymous says:

    < ![CDATA[

    What should the scroll setting be like

    ]]>

  22. Anonymous says:

    < ![CDATA[

    What should the scroll setting be like

    ]]>

  23. Anonymous says:

    < ![CDATA[

    Whatever you want, but make sure you can scroll the screen.


    Set it to both in case you are not sure.

    ]]>

  24. Anonymous says:

    < ![CDATA[

    Sorry, I need to disconnect.


    The only thing I can think of is to check if the scripts execution is enabled:


    Long click the desktop background.


    Lightning settings


    All settings


    General


    Run script-checked



    If you still can’t we will try tomorrow.

    ]]>

  25. Anonymous says:

    < ![CDATA[

    Okay thanks for your time

    ]]>

  26. Anonymous says:

    < ![CDATA[

    Hello, I’d like to use this script, but I’d like it at the bottom, just like the G+ android app. 


    I don’t know anything about scripting, and I’ve tried to change the bar.setposition (posx,0) by “posx,1280”


    The panel goes to the bottom but I can’t change the hide position …


    If you have the time can you explain me, please, or


    another idea : is it possible to have several position as you did with “customisable wheel of item” 


    Thanks in advance

    ]]>

  27. Anonymous says:

    < ![CDATA[

    In fact I wanted to make it, but when I did this script it was early and there were a lot of things to try.


    Thanks to bring it 🙂


    I hope to modify it to be at the bottom and send it to you soon, the possibility to place it where you want will need to wait a bit more.

    ]]>

  28. Anonymous says:

    < ![CDATA[

    Thank a lot TrianguloY 😉

    ]]>

  29. Anonymous says:

    < ![CDATA[

    Ah, I like when things go easy (more or less).


    Ok, this is the script with both: horizontal and vertical.


    Could you test it?



    [EDIT: hey! I was writing this right now xD]

    ]]>

  30. Anonymous says:

    < ![CDATA[

    //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



    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


    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]


    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]);

    ]]>

  31. Anonymous says:

    < ![CDATA[

    TrianguloY : you’re too quick ! 🙂


    I have tried it quickly, the bar goes to the bottom but don’t show it entirely, horizontal position doesn’t work. I’ll test the script more tonight, and try to make a video to show you how it run. Thanks again

    ]]>

  32. Anonymous says:

    < ![CDATA[

    Make sure that you can scroll the desktop, otherwise the bar won’t move.


    The horizontal position is disabled by default. To enable just change the “horizontal=0” to “horizontal=1” (or -1) at the beginning of the script

    ]]>

  33. Anonymous says:

    < ![CDATA[

    Every thing works like a charm 😉


    Just need to enable “no scroll limit” otherwise sometime the script work and sometime not. Thanks again it’s perfect as usual 🙂

    ]]>

  34. Anonymous says:

    < ![CDATA[

    Hello, it’s me again … :-\ sorry, but if I copy/paste the part “down”of the script, in the “up” part, will it change the gesture, as when I scroll down it hides the bar ? Or I have to change “>” by “< " or maybe it's an another script ? No need to write a new script it's just to understand

    ]]>

  35. Anonymous says:

    < ![CDATA[

    The down part and the up part mean the direction of the scroll (also left/right ), perhaps both can be put together but…it works now.


    I know my scripts are not easy to understand (sorry) and I will try to answer any question you made.



    What happen if you copy the down part in the up part? Well, if you don’t change anything more it will scroll down twice fast and won’t scroll up 😛

    ]]>

  36. Anonymous says:

    < ![CDATA[

    Thanks, I’ll add a new script and try to make few changes just to test. ¡ Muchas gracias !

    ]]>

  37. Anonymous says:

    < ![CDATA[

    ;P

    ]]>

  38. Anonymous says:

    < ![CDATA[

    TrianguloY you are a sorcerer and saint all in one, it’s communication like this between dev and user that keeps our Android community strong 🙂

    ]]>

  39. Anonymous says:

    < ![CDATA[

    Thanks Sree Rao, that means a lot

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *