Hello. When an event occurs, the previous values should be stored. For example:
var old_value = 0; window.onscroll = function() { var new_value = window.pageYOffset; if(new_value!=old_value) ...//какие-то действия old_value = new_value; } } But so old_value is in the global scope, which is good.
I read about closures and context binding , but I am not sure that this is what is needed to solve this problem.
Tell me, how is such a task properly implemented? Or is this only possible using global variables?