0

I know there are a lot of smooth scroll scripts on stack, and I have adopt them a lot in the past. As I do not want to use <a href="#"> links, I am using <buttons data-href="">. This is my current code:

var $root = $('html, body');
$('.smooth').click(function() {
        var href = $.attr(this, 'data-href');
        $root.animate({
                scrollTop: $(href).offset().top
        }, 500, function () {
                window.location.hash = href;
        });
        return false;
    alert('smoothness');
});

And the necessary html part:

<button id="downarrow" data-href="#features" class="smooth">
  <span>scroll down</span>
</button>

This works great, as seen right here: DEMO

I do not know why, but it does not work in my live site with the same code. You can check its build here: FULL DEMO

Marian Rick
  • 3,350
  • 4
  • 31
  • 67
  • Possible duplicate: http://stackoverflow.com/questions/3870057/how-can-i-update-window-location-hash-without-jumping-the-document. Check if that helps. – krato Mar 08 '16 at 11:38

1 Answers1

1

It was a CSS issue with this line :

I removed "overflow" property of this :

article#wrapper{height:100%;width:100%;}

You can see it in your fiddle right here

Vincent G
  • 8,547
  • 1
  • 18
  • 36
  • Thanks for pointing me to the right direction. As the `header {position: fixed}` is not a bug, I suggest you remove this from your answer. Removing `overflow: auto` from my `#wrapper` is the only necessary thing to do! :) thanks for your help! – Marian Rick Mar 08 '16 at 14:00
  • You're right about "header {position: fixed}" line. Glad to help you ! :) – Vincent G Mar 08 '16 at 14:04