Houge
Member
|
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?
P.S. It would be great to make it like build log in EE editor
(This post was last modified: 05-18-2017 03:02 PM by Houge.)
|
|
05-18-2017 02:18 PM |
|
Zervox
Member
|
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 |
|
Houge
Member
|
RE: Automatic scrolling
Yes, but it doesn't do what i need.
|
|
05-18-2017 03:52 PM |
|
Zervox
Member
|
RE: Automatic scrolling
the scrolling or the detection of how close it is to the end?
|
|
05-18-2017 04:00 PM |
|
Houge
Member
|
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 |
|
Esenthel
Administrator
|
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 |
|
Houge
Member
|
RE: Automatic scrolling
Thank you very much!
|
|
05-19-2017 05:28 AM |
|