Jquery making things happen while side scrolling (scrollto.js) - only works if scrolling slowly -


on horizontal parallax site using jquery scrollto(awesome...) attempting use windowsize values , scrollleft values in making decisions knowing current page width - if resized. that's working.

when window widths hit or moved through while scrolling left right, want set value on nav items provide guidepost next mark. using alerts/test codes shown below verify points hitting. , - if scrolling slow.

any ideas on catching these numbers cleanly , reliably? seems it's firing fast jquery not getting it. or not viewing correctly?

function parallaxscroll(){      var scrolledx = $(window).scrollleft();     var windowsize = $(window).width();      var win0 = 0;     var win1 = windowsize;     var win2 = windowsize * 2;     var win3 = windowsize * 3;      if (scrolledx == win1) {         $("#test").text("mark1");     }     if (scrolledx == win2) {         $("#test").text("mark2");     }     if (scrolledx == win3) {         $("#test").text("mark3");     }  } 

it's hard catch exact size. size, , larger - example, if win1 100, it'll fire @ 100-199, win2 if it's @ 200-299, , on.

note check window sizes largest smallest (you can them smallest largest, sure change > < , add check sizes larger win3.

also, make checks if ... else if ... else statemnts don't accidentally fire multiple times (win3 larger win2, win2 fire @ win3).

function parallaxscroll(){    var scrolledx = $(window).scrollleft();   var windowsize = $(window).width();    var win0 = 0;   var win1 = windowsize;   var win2 = windowsize * 2;   var win3 = windowsize * 2;    if (scrolledx >= win3) {     $("#test").text("mark3");   }   else if (scrolledx >= win2) {     $("#test").text("mark2");   }   else {     $("#test").text("mark1");   }  } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -