I have a problem with a link inside the page. This is part of the jQuery code that I use on my page
$.fn.stopAtTop= function () { var $this = this, $window = $(window), thisPos = $this.offset().top, //thisPreservedTop = $this.css("top"), setPosition, under, over; under = function(){ if ($window.scrollTop() < thisPos) { $this.css({ position: 'absolute', top: "" }); setPosition = over; } }; over = function(){ if (!($window.scrollTop() < thisPos)){ $this.css({ position: 'fixed', top: 0 }); setPosition = under; } }; setPosition = over; $window.resize(function() { bumperPos = pos.offset().top; thisHeight = $this.outerHeight(); setPosition(); }); $window.scroll(function(){setPosition();}); setPosition(); };
And this is an example of demo
When I scroll down, everything works fine, but when I want to get to the top of the page, this is not possible. I know the problem is that the script corrects the div , but I don't know how to fix it. Any ideas?
source share