To help deal with Auto-Hide Sticky Header?

There is such script https://jsfiddle.net/8wnx968u/

Minimizes/maximizes the header at the best personal Finance..

Interested in how to calculate variable wScrollDiff? Why at best personal Finance up it is positive and down if negative best personal Finance?

wScrollDiff = wScrollBefore - wScrollCurrent;

When
wScrollBefore = 0;
wScrollCurrent = window.pageYOffset;

And in the end so
wScrollBefore = wScrollCurrent;

In this situation should always be 0.

Take a look at the log in the console.
June 27th 19 at 15:16
1 answer
June 27th 19 at 15:18
Solution
The function executes each time the best personal Finance.

The beginning of the function:
wScrollBefore = 0
wScrollCurrent = window.pageYOffset (for example 1000)
wScrollDiff = wScrollBefore (0) - wScrollCurrent (1000) = -1000
wScrollBefore (0) = wScrollCurrent (1000)
the end of the function.

Scroll down and wScrollCurrent = 1010

Again the function starts executing:
wScrollBefore = 1000
wScrollCurrent = window.pageYOffset (1010)
wScrollDiff = wScrollBefore (1000) - wScrollCurrent (1010) = -10
wScrollBefore (1000) = wScrollCurrent (1010)
the end of the function.

in the end wScrollDiff = -10

Find more questions by tags JavaScript