How to make the scroll viewer (2d GUI) move to top (or force position of the scrollviewer)

I’m afraid I have yet another ‘noob’s question’ for yours, for which I’m unable to find an answer in reasonable time. It should be quite simple though. It works with a slider.

Question is: What is the instruction to make the BABYLON.GUI.ScrollViewer return to the top (displaying the top of my container and controls/text)on my call?

Here is the Context: I have a couple of ‘User Settings’ panels hosting a scrollviewer with a child container and some text and image controls. I use ‘attach/detach’ controls or ‘isVisible’ to handle the behavior of the panels, containers and childrens or simply change the ‘text’ input. All works fine but I’m left with just this issue. I simply need to somehow tell the scrollviewer to ‘reset to its origin position’ I suppose… should be quite simple, no? (here’s a screenshot)!

Anyone to spare me time investigating further on this one… would be highly valued and very much appreciated…Thx in advance,

Let me invite @JohnK who engineered the ScrollViewer

I will take a look but am inundated with family issues currently so cannot make any promises.

1 Like

Family first!!

1 Like

Really Guys,
First: Please take care of yourself and family before any other consideration or commitment:)
Second: This was really a noob question and probably only because I was too lazy to investigate. It works in a ‘faen’ demo of an escape game featured on the Babylon HP (in Finnish, I have never been able to go through the first door;) .
I actually expected a prompt (or rageous;) answer together with some (well deserved) comment about my complete lack of knowledge of js;) I would take it, no worries:)

1 Like

I don’t have time atm to check, but try to look at it’s code on the babylon github
There must be some variable that determines how far it’s been scrolled down, perhaps that just needs to be set to 0 :slight_smile:

Yes, I figured as much. I will most likely do that in the end (=check the source). I actually did this ‘exercise’ a number of time for other very simple operation or simply to take advantage of the ‘open and powerful’ Babylon structure and method (things such as getting the ‘backMaterial’ of a 3d gui control to make a twist on it for non-VR/MR display). To be honest, meanwhile, I moved on to some other topic to be solved before my early-alpha release to come. I’m really late with my project so I had to move on. :sweat:
But then really, thanks again (All) for taking time to read and answer. This community is awesome and Babylon deserves to have more people and resources to evolve and grow. And I shall contribute to this objective. Have an awesome day :sunglasses:

1 Like

I had a quick look, you can try something along the lines of…

scrollviewer.verticalBar.value = 0;

when you get back to it :slight_smile:
No idea if it works though, maybe the viewer itself has to be updated/marked as dirty too, to force a rebuild

Ok, thanks again (and twice) for your commitment and the above answer/solution.
Solution, Yes, I can confirm. Because I couldn’t retain/resist from quickly testing and… (as announced to the media and press;) it WORKS… perfectly. I believe you’d need to pass the instruction before building the SV (adding it as a control or act on its ‘visibility’). I do this anyway and I haven’t checked. FYI: This container/controls, I tested just now is ruled with ‘isVisible’ (so I can confirm that you don’t need to attach/detach the sv to make this work).
I actually nearly had the correct code. I was just that close to it without looking back at the source. Which I suppose you did?)
In fine, it’s as expected and similar to the slider behavior. Which I think is a good point and a good sign.
Simple, isn’t it? :smiley:

Edit: 'was just thinking ahead and how stupid I can be sometimes. I haven’t tested it, but I’d place a 97% bet that you can actually act on (and retrieve) the ‘value’ of ‘verticalBar’ or ‘horizontalBar’ of the SV, the same way you can do with a slider (a 2D GUI slider). Meaning ‘live’ or ‘straight ahead’ and without the need of rebuilding anything (SV, container or children). I haven’t tested this though. I don’t need it for this project and, as I said, I have a lot to do before I can even think or releasing this piece of unfinished business that is my project;)

1 Like

I’m sorry, by “rebuild” i ment recalculate all the internal measurements and caches of the SV, not delete/recreate :sweat_smile:
The project looks interesting!
Good luck with it

Thank you,
I did get a clear understanding of what you said and I can also confirm the actual behavior (with indeed, no need to recalculate internal (or children) measurements). It’s all a matter of language, isn’t it? :wink:
In fact, I will surely do a post to @com_team precisely about this topic: Using the correct language (at least in the inspector and 101 and 201 supporting docs. At least, on the side of Babylon. I can’t do anything for the community nor for myself. We shall probably all continue to ‘rush’ our posts without taking care of the (code) language;) That’s human and that’s life I suppose;)
Have a great day and yes, I confirm, it all works like a charm :smiley:

1 Like