scroll - Jquery slider using scrollTo buggy -
i trying develop jquery slider using popular slideto plugin. have whipped jfiddle can see example of slider made, code: http://jsfiddle.net/mh7mh/
the result buggy. doesn't seem loop around when have reached last slide, , should. take @ jquery - created if statement resets variable tells scrollto scroll to. code pretty self explanatory.
any fixing huge help. thanks!
you have multiple bugs in logic of functions. here's revamped version of js:
// defining these vars in every function, not global vars var jesse = 0; var lastslide = 3; // numslide var off one, renamed lastslide // adding these events multiple times each li $("#controls a.next").click(function() { (jesse==lastslide)?(jesse=0):(jesse++); $("#contentslider").stop().scrollto('li:eq(' + jesse + ')', 500); return false; }); $("#controls a.prev").click(function() { (jesse==0)?(jesse=lastslide):(jesse--); $("#contentslider").stop().scrollto('li:eq(' + jesse + ')', 500); return false; }); the usage of ?: called ternary operation. similar if/else statement.
it's general usage is:
foo=(booleanexpression)?bar:baz; // equal if(booleanexpression){ foo=bar; }else{ foo=baz; }
Comments
Post a Comment