B
B
Boris Belov2015-09-21 20:48:14
PHP
Boris Belov, 2015-09-21 20:48:14

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

2 answer(s)
I
Ivan Tokar, 2015-09-21
@Jonathan

Try this plugin
Waypoints

var waypoint = new Waypoint({
  element: document.getElementById('thing'),
  handler: function(direction) {
    alert('You have scrolled to a thing')
  }
})

D
Dmitry Pyrkin, 2015-09-22
@ps1panda

window.onmousewheel = function(){
    var delta = e.deltaY || e.detail || e.wheelDelta;
    if(delta>0){
        console.log('down')
    }
    else if(delta<0){
        console.log('up')
    }
    
    }

Something like that

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question