Please check if this works for you: https://jsfiddle.net/kr85k3us/4/
I tested it and it should work, but maybe you can move the mouse wheel faster :)
if (!canScroll && lScroll == 0) { var first = Object.keys(boxes)[0]; if (boxes[first]['y'] < 10) { var delta = 10 - boxes[first]['y']; Object.keys(boxes).forEach(function(k){ boxes[k]['y'] += delta; }); } }
This is the part of the code that I added. If you cannot scroll, and lScroll is 0, this means that we have reached the top. Then I check if the first field is where it should be. If not (ie boxes[first]['y'] < 10 ), then it adjusts all the positions of " y ".
source share