Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vertical scrolling is scrolling in the wrong direction #228

Open
czinczaar opened this issue May 24, 2023 · 4 comments
Open

vertical scrolling is scrolling in the wrong direction #228

czinczaar opened this issue May 24, 2023 · 4 comments

Comments

@czinczaar
Copy link

Hi,
not sure it if is me or not, but I can't get a vertical scroll component to scroll in the right direction. Is there a way to change scrolling direction? I have a box node with a druid text node inside. The parent clipping mode is set to stencil.
Here is a short video of the problem https://streamable.com/5o5nvi
And here is how I create the scroll component:
local druidParagraphScroll = self.druid:new_scroll(paragraphNode, paragraphTextNode) :set_extra_stretch_size(0) :set_inert(false) :set_horizontal_scroll(false)

@Insality
Copy link
Owner

Hello! The issue will be in GUI node sizes setup for scroll view and scroll content nodes

Please take note how the GUI is adjusted in examples, they have the vertical scrolls (at least in main menu)

You should adjust the scroll content position, anchor and node sizes

Try to set the anchor to North to both of nodes, position to 0:0 and make a size of content bigger than view

@czinczaar
Copy link
Author

Thanks for the response! I have been taking a long look at the example and I have made some progress. I guess the way my nodes were set up was wrong.

Now I am facing a different problem: to make it short, I use druid to scroll on text which has a size that is only known at run time, and so I have to limit the scrolling after the end of the text.
Here is the bit of code that should do it, in on_input:
if self.druidParagraphScroll.position.y > self.maxScroll then self.druidParagraphScroll:scroll_to(vmath.vector3(0, self.maxScroll, 0), false) end
self.maxScroll is the Y size of the whole text. This is to prevent the player to scroll below the end of the text since there is nothing to see there. So I want to scroll_to that position but it always scrolls back to the beginning of the text instead of scrolling to self.maxScroll.

Thanks for your time!

@Insality
Copy link
Owner

Seems like you trying to handle scroll work by yourself, since the Scroll component can handle it by default

You should change the scroll content size via scroll:set_size and it should be ok. You can't handle the position value and use scroll_to to restrict the scrolling

All you need is scroll:set_size in your case

@czinczaar
Copy link
Author

Hey, thank you I finally got it to work correctly!
I have made a small guide here for those who would struggle like me with the scroll component:
https://forum.defold.com/t/short-guide-on-how-to-use-the-druid-scroll-component/73376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants