jquery - Can you make a scrollable div maintain the size of the scrollback using FIFO -
so have div container following css
#game-container { background-color: #000000; color: #ffffff; border: thick solid #808080; height: 400px; word-wrap: break-word; overflow: auto;}
i use function keep scrollbar @ bottom of container.
function scrolltobottom(container) { var messages = $(container); messages.scrolltop(messages[0].scrollheight); }
it works expected , data appended container scrolls up. want limit amount of scrollback container holds using first in first out method of maintaining contents of container. if container holding 20 lines or pixels or whatever measurement used in scrollback toss out first contents , maintain size new content appended, tossing out first content grows.
you may want remove first element child(ren) in container until minimum height has been attained.
the best moment after you've inserted new content bottom of container.
regarding removing child elements, may refer answers posted here , here.
Comments
Post a Comment