Answer the question
In order to leave comments, you need to log in
How to specify a smooth scroll to the top (Back to top), when scrolling up?
Good evening.
There is such a question:
We all know how to do back to top in order to climb to the top of the page.
But the client requested the ability to go to the top of the page when scrolling up.
That is, if we scroll down, then the "back to top" icons should not be there. And if we start scrolling up, then the icon should appear.
How to achieve this?
Imagine, using the example of such jsfiddle.net/velcrobots/6qrQF/1
Answer the question
In order to leave comments, you need to log in
Try this plugin
Waypoints
var waypoint = new Waypoint({
element: document.getElementById('thing'),
handler: function(direction) {
alert('You have scrolled to a thing')
}
})
window.onmousewheel = function(){
var delta = e.deltaY || e.detail || e.wheelDelta;
if(delta>0){
console.log('down')
}
else if(delta<0){
console.log('up')
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question