scroll - jQuery algorithm scrolling speed -


there dwo divs #leftpane , #rightpane. #leftpane has position relative , browser set scrollbar acording height, meanwhile #rightpane has position: fixed , add top: -value while scrolling, 'scroll' secont div different speed. want achieve scrollspeedmodifier according 1. browser window height, 2 leftpane content height , 3 rightpane content height (2,3 content height might different each time).

so while scrolling #leftpane - if content of #rightpane bigger #leftpane top value grow faster normal scrolling, when #rightpane content height smaller #leftpanes top value grow slower normal scroling.

this way count speed right now:

ar scrollspeed = (rightpaneheight) / browserheight; 

but it's wrong, middle of #rightpane , when change 'browser' size (jfiddle window size) might till end of #rightpane.

this code end far:

http://jsfiddle.net/bvfcx/15/

ok fixed, http://jsfiddle.net/bvfcx/21/

the right algorithm is:

-$(window).scrolltop() * ((browserheight - rightpaneheight) / (browserheight - leftpaneheight)); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -