About Store Forum Documentation Contact



Post Reply 
Automatic scrolling
Author Message
Houge Offline
Member

Post: #1
Automatic scrolling
Hello!

I have a region for chat messages, i need to make my region auto scroll to last message at the bottom only if the scroll is at he bottom, and if i scroll up to read old messages it should not automatically scroll when new message appears.
If i check scroll position like this:
Code:
if(T.slidebar[1].offset() >= T.slidebar[1].lengthTotal() - T.slidebar[1].length())
{
    T.scrollY(9999, true);
}

It performs very bad with immediate=false, because it takes current position which != lengthTotal().

Maybe someone has an idea how to do this correctly? smile

P.S. It would be great to make it like build log in EE editor smile
(This post was last modified: 05-18-2017 03:02 PM by Houge.)
05-18-2017 02:18 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: Automatic scrolling
To my knowledge scrollY() is a delta value, so 1 is max.
the code scrollY() scrolls with slidebar::scroll

I believe if you do
T.slidebar[1].scrollTo(T.slidebar[1].lengthTotal()); would equal the same but work with lengthTotal.
05-18-2017 03:09 PM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #3
RE: Automatic scrolling
Yes, but it doesn't do what i need.
05-18-2017 03:52 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: Automatic scrolling
the scrolling or the detection of how close it is to the end?
05-18-2017 04:00 PM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #5
RE: Automatic scrolling
When new message is added scroll only when i'm at the end.
(This post was last modified: 05-18-2017 05:32 PM by Houge.)
05-18-2017 05:32 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Automatic scrolling
Editor uses this code:
Code:
SlideBar &sb=build_region.slidebar[1];
Bool at_end=(sb.offsetDesired()+sb.length()>=sb.lengthTotal()-0.02f);
if(at_end)build_region.scrollY(9999); // auto-scroll to the end

I will add this method to the SlideBar class:
Code:
Bool wantedAtEnd(Flt eps=EPS)C {return offsetDesired()+length()+eps>=lengthTotal();} // if slidebar is wanted to be at the end
05-19-2017 12:54 AM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #7
RE: Automatic scrolling
Thank you very much!
05-19-2017 05:28 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply