I think Andy has the right idea measuring the incoming elements before adding them.
As an alternative to scrollBy (which may work fine) it may be simpler to have a wrapper element that you prepend the items to and simply move that element "up" by subtracting the added height from the current Y position. That would eliminate the need to track the current position at all because you're always adding and moving the same amount at the same time. Haven't tested it, but hopefully some help in finding a solution. On Apr 9, 10:15 pm, Andy Couch <[email protected]> wrote: > Maybe someone else will have a better idea, but the first thing that comes > to mind is to grab the div via ajax, measure the height, then append it and > use scrollBy to scroll the view the same amount as the height of the div. > The trickier part would be keeping track of the current scroll position > with each insert and making sure it's updated with each scroll event so the > current content is always in view. > > > > > > > > On Mon, Apr 9, 2012 at 9:54 PM, Paul Menard <[email protected]> wrote: > > Greetings all. Working on a project where I have a fixed height outer > > wrapper div. Then within the div I have other div elements in a list. I've > > setup the JS to pull in new items from the server via AJAX. new items > > retrieved via AJAX are prepend top of the list. This is sort of like a > > realtime log events. The AJAX and prepend are working but when the prepend > > happens the item(s) are immediately visible. I want to prepend but keep the > > top of the list items hidden. Then let the user scroll to the new items. > > > So for example the height of the wrapper div is 450px. And there are > > initially 50 items in the list. So the wrapper div will scroll. Visible at > > the time are items 50-41 to top 10 items of the list. The other 40 items > > are below the scroll area. The AJAX call fires and pulls in 10 new items > > 51-60 which are prepended to the top of the listing. I want to just perform > > the prepend but keep the current visible items showing items 50-41. > > > I've tried the outer wrapper as <ul> and list items <li></li> still did > > not work. > > > Thoughts? > > > P- > > > -- > > Our Web site:http://www.RefreshAustin.org/ > > > You received this message because you are subscribed to the Google Groups > > "Refresh Austin" group. > > > [ Posting ] > > To post to this group, send email to [email protected] > > Job-related postings should followhttp://tr.im/refreshaustinjobspolicy > > We do not accept job posts from recruiters. > > > [ Unsubscribe ] > > To unsubscribe from this group, send email to > > [email protected] > > > [ More Info ] > > For more options, visit this group at > >http://groups.google.com/group/Refresh-Austin -- Our Web site: http://www.RefreshAustin.org/ You received this message because you are subscribed to the Google Groups "Refresh Austin" group. [ Posting ] To post to this group, send email to [email protected] Job-related postings should follow http://tr.im/refreshaustinjobspolicy We do not accept job posts from recruiters. [ Unsubscribe ] To unsubscribe from this group, send email to [email protected] [ More Info ] For more options, visit this group at http://groups.google.com/group/Refresh-Austin
