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

Is "auto scroll" possible ? #32

Open
RegniesAnthony opened this issue Dec 11, 2020 · 1 comment
Open

Is "auto scroll" possible ? #32

RegniesAnthony opened this issue Dec 11, 2020 · 1 comment

Comments

@RegniesAnthony
Copy link

Hi,
I would like to use it for a chat, so i need to automaticly scroll to the bottom of my scroll box each time i create a scroll box (to watch the most recent messages) is it possible currently ? i didn't find how.

Is there a value that i am supposed to change ?

=================

const scrollBox = new Scrollbox.Scrollbox ({ boxWidth: HUDChatWidth, 
                                                boxHeight: HUDChatHeight,
                                                contentWidth: HUDChatWidth*0.9,
                                                contentHeight: HUDChatHeight*0.9,
                                                dragScroll: true,
                                                scrollbarOffsetHorizontal : 0,
                                                underflow: "none"})

        chat.forEach(m => {
            text += m +"\n";
        })
        scrollBox.content.addChild(new PIXI.Text(text, {fontFamily : 'Arial', 
                                                        fontSize: 24, 
                                                        fill:0xCCCCCC, 
                                                        align : 'left', 
                                                        wordWrap:true, 
                                                        wordWrapWidth: HUDChatWidth -24, 
                                                        height: HUDChatHeight-10, 
                                                        breakWords:true}));
        //here, scroll to the bottom of my scrollBox ?
        scrollBox.update();
@davidfig
Copy link
Owner

You need to set the bottom of the viewport: scrollbox.content.bottom = scrollbox.content.height should do the trick.

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