W
W
wiyod2018-02-26 23:52:51
JavaScript
wiyod, 2018-02-26 23:52:51

How to change the values ​​to the opposite mirror?

const value = (scrollTop/trackLength).toFixed(2)
Where scrollTop is window.pageYOffset and trackLength is the total page height of the site. The values ​​of value change as you scroll FROM 0 (scroll at the top of the screen) to 1 (scroll at the very bottom).
How to change the values ​​to the opposite mirror? Those. when 0 i want 1, when 0.20 i want 0.80 and so on?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2018-02-26
@wiyod

y = Math.abs(1 - x)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question