javascript - Scroll to bottom of page, only if the user already was at the bottom before DOM manipulation -


i'd learn how use window.scrollto.

here's desired behavior:

  1. determine if user scrolled bottom of page, or no scroll bar visible
  2. then want grow div, working
  3. if #1 true, use window.scrollto scroll bottom of page after div has grown changed window height.

ideas?

working han's idea, can detect whether window scrolled bottom this:

$('button').click(function(){     var shouldscroll = $(document).scrolltop() + $(window).height() === $(document).height();     $('<div>added content</div>').appendto('body');     if(shouldscroll) {       $(window).scrolltop(document.body.scrollheight);     } }); 

updated jsfiddle here: http://jsfiddle.net/jameskovacs/nqntc/1/


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -