javascript - Stay in the same position after a jQuery's slideUp -


when click div (x), expands using .slidedown(), height increased, when detect scroll pass element (when x no longer in viewport), using inview plugin, close .slideup(), increased height goes normal state, instead of being @ (y), i'm @ (z)

after .slidedown()

x x x x y  <-- arrive here scrolling y z z 

after .slideup()

x x <-- height decreased y <-- instead of being here.. y  z <-- i'm here. z 

how can stay in same position after element's height decreased?

demo

whenever .slidedown() triggerd current srolltop position of page , set scroll position after .slideup() triggered. can use below code.

//get current position of page var pageposition = $(window).scrolltop();                 //set page position after `.slideup()` called $("html,body").scrolltop(pageposition); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -