jquery - Detect how much horizontal bar moved from the beginning -


i have fixed div, wanted move , down not left , right, , managed answer.

the issue is, if scroll example end of page right, , scroll down, fixed div there, want show if horizontal bar @ beginning (or moved bit right)

is possible detect if horizontal bar has moved amount of pixels begnning? because change css dynamically on div after horiz. bar has been moved example 100px right.

css , html:

#test {      width: 100px;     height: 100px;     background: red;     position: fixed;     left: 0;     top: 100px; }  <div id="test">&nbsp;</div> 

jquery:

$(function () {      var lastscrollleft = 0;     jquery(window).scroll(function() {         var documentscrollleft = jquery(document).scrollleft();          if (lastscrollleft != documentscrollleft) {             jquery('#test').attr('style', 'position:absolute;left:0px;')             lastscrollleft = documentscrollleft;         }     });       var lastscrolltop = 0;      jquery(window).scroll(function() {         var documentscrolltop = jquery(document).scrolltop();         if (lastscrolltop != documentscrolltop) {             jquery('#test').attr('style', 'position:fixed;left:0px;')             lastscrolltop = documentscrolltop;         }     }); }); // end ready 

to sum up:

inside second scroll function, want change div position absolute if page has been scrolled 100px right.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -