jquery - Scroll window to the top of a div after sibling slideToggle -


hi there: have page of articles in divs start off hidden behind clickable banners. every time click banner, extends relevant article div slidetoggle , closes other article div open slideup. i've got following code, which, if view starts off above final position of clicked banner div, scrolls window down div; however, if article closes above div, move out of view, , window doesn't scroll it. how can fix this?

$(document).ready(function () {     $(".entry-title-thumbnail-active").click(function () {         $(this).closest('.site-content').find('.entry-content-thumbnail').not($(this).closest('article').find('.entry-content-thumbnail')).slideup('slow');         $(this).closest('article').find('.entry-content-thumbnail').slidetoggle(             'slow', 'swing', $('html,body').animate({             scrolltop: $(this).offset().top         }, 'slow'));         return false;     }); }); 

basically, logic moves dom tree parent .site-content div, contains banners , article divs, finds child .entry-content-thumbnail divs , slides them - excluding sibling of clicked .entry-title-thumbnail-active - ensure no other articles showing. moves 1 level tree again article div containing sub-elements, , finds .entry-content-thumbnail within div , extends it.

the problem is, if div slideup above div doing slidetoggle open, top of article pulls out of view, makes not-great reading experience. i'm trying window scroll clicked .entry-title-thumbnail-active.

i put in jsfiddle here: http://jsfiddle.net/jguilford/vzvcd/

any appreciated!


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -