Ryan Gahl
2006-Mar-08 20:24 UTC
RE: question about auto-updating div withoverflow:auto and maintaining position
You should be able to do this by changing the div''s .scrollTop value via javascript (maybe just pick a very large number to ensure bottom is hit, like 10,000). -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Jeremy Kitchen Sent: Wednesday, March 08, 2006 2:21 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] question about auto-updating div withoverflow:auto and maintaining position I have a div (with overflow:auto) that gets stuff added to it via Ajax.PeriodicalUpdater, and I''d like to keep it scrolled to the bottom all the time, unless the user manually scrolls away from the bottom (and be able to return it to its bottom-sticky form afterwards) I''m not sure if this is just some css trickery I need to do, or if it requires some javascript to do it. Here''s what I have so far (yes, I''m creating an online chat interface) http://edge.scriptkitchen.com:81/~kitchen/chat.html I tried putting a <a name="bottom" id="bottom" /> at the bottom of the div, and an oncomplete with effect.scrollto(''bottom'') but that didn''t do anything, presumably because effect.scrollto is checking the scroll position of the overall window (which should theoretically never scroll) rather than the scroll position of the div itself. Any help would be greatly appreciated :) Thanks! -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.
Jeremy Kitchen
2006-Mar-08 20:27 UTC
Re: question about auto-updating div withoverflow:auto and maintaining position
On Wednesday 08 March 2006 12:24, Ryan Gahl wrote:> You should be able to do this by changing the div''s .scrollTop value via > javascript (maybe just pick a very large number to ensure bottom is hit, > like 10,000).good call :) Now to figure out if the user is actually scrolled all the way to the bottom (I figure I won''t force a scroll if they aren''t at the bottom, signalling to me that they''ve scrolled themselves :) I''ll play around with some of this over lunch :) Thanks for the help. -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Jeremy Kitchen
2006-Mar-08 23:39 UTC
Re: question about auto-updating div withoverflow:auto and maintaining position
On Wednesday 08 March 2006 12:27, Jeremy Kitchen wrote:> On Wednesday 08 March 2006 12:24, Ryan Gahl wrote: > > You should be able to do this by changing the div''s .scrollTop value via > > javascript (maybe just pick a very large number to ensure bottom is hit, > > like 10,000).what I ended up doing is this: <div id="wrap" style="overflow:auto"> <div id="inner"></div> </div> then in my javascript I did: $(''wrap'').scrollTop = $(''inner'').offsetHeight;> good call :) Now to figure out if the user is actually scrolled all the > way to the bottom (I figure I won''t force a scroll if they aren''t at the > bottom, signalling to me that they''ve scrolled themselves :)I went the lazy route and added a checkbox ;) Thanks again for the help! -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Possibly Parallel Threads
- question about auto-updating div with overflow:auto and maintaining position
- prototype-ish subclassing
- generic onDragStart onDrag and onDragFinish events extracted from scriptaculous?
- [prototype] Selector class fails on selector strings with spaces
- Effect.toggle error in 1.6.1