How to enable smooth scrolling to anchors in JavaScript

If you are building a website the hard way, using front-end frameworks like Bootstrap or Foundation for example, you may have noticed how brutal the transition is from one anchor to another. There is no smooth scrolling.

To remedy this indelicacy and to soften the user experience, you can implement a quick solution using JavaScript.

Just copy-paste this code snippet, before the </body> tag at the end of your HTML document, and you’re good to go!

<script>
$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});
</script>

Patagonia time-lapse in 8K resolution

Patagonia 8K explores the beautiful and rough landscapes of southern Chile and Argentina. Shot in 8K resolution on a medium format camera, this time-lapse is aimed to deliver the most realistic experience.
Shot in 6 weeks, travelling over 7500km from Santiago to Punta Arenas, the team of TimeStorm Films captured roughly 100.000 still frames that combine into this timelapse video.

Robbie Maddison’s “Pipe Dream” – The dawn of motosurfing

Now this is the most epic video of 2015. Surfing big waves takes a lot of guts and preparation, but riding a motorbike on big waves? That is an incredible project.

I think Robbie Maddison just invented a new sport: motosurfing. In the future, his motosurf will be enhanced, new people will try to make the same thing, costs will fall and it will be available for more and more people. Be prepared to see new videos like this one very soon!

The Kelly Kut – a montage on Kelly Slater

Incomparable and iconic. The surfer’s surfer. 11-time World Champion, Kelly Slater’s scope of influence has spanned three decades and, like a fine wine, he’s only gotten better with age. This retrospective juxtaposition to his modern approach reveals how innovative, fluid and unforced his style has always been: perfect. #thekellykut