Answer the question
In order to leave comments, you need to log in
Which image upload for Yii would you recommend?
What image upload do you use and on which yii?
Answer the question
In order to leave comments, you need to log in
If you assign a value to tempScrollTop before comparing to currentScrollTop , then you replace the previous value in tempScrollTop with currentScrollTop and your subsequent checks fail because the variables are now equal.
Read more about if's to avoid such questions.
If the assignment (equating) of variables at the top:
You have them equal by default at any moment of the scroll, there is no entry into if.
As I understand it, you want to display "up" and down - "down" when scrolling up, on each scroll?
To do this, you need to save the previous position and compare with it (initially it should be at zero).
var tempScrollTop=0,
currentScrollTop;
$(window).scroll(function(){
currentScrollTop = $(window).scrollTop();
if (tempScrollTop < currentScrollTop ){
alert("Вниз");
}
else if (tempScrollTop > currentScrollTop ) {
alert("Вверх");
}
tempScrollTop = currentScrollTop;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question