pixi-scrollbox icon indicating copy to clipboard operation
pixi-scrollbox copied to clipboard

Is "auto scroll" possible ?

Open RegniesAnthony opened this issue 4 years ago • 1 comments

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

RegniesAnthony avatar Dec 11 '20 23:12 RegniesAnthony

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

davidfig avatar Dec 11 '20 23:12 davidfig