Response title
This is preview!
I need to animate a scroll from the current screen position up or down, when the scrollbar move up or down.
I'm using this script, but doesn't work ok:
- var iScrollPos = 0;
- $(window).scroll(function () {
- var iCurScrollPos = $(this).scrollTop();
- if (iCurScrollPos > iScrollPos) {
- $('html,body').animate({
- scrollTop: $(window).scrollTop() + 100
- })
- } else {
- $('html,body').animate({
- scrollTop: $(window).scrollTop() - 100
- })
- }
- iScrollPos = iCurScrollPos;
- });
The problem is that a loop appear on the scroll down.
© 2013 jQuery Foundation
Sponsored by and others.