1

I'm trying to implement some JavaScript code I found here on stackoverflow to make a smooth transition between one link on a page and other section in other page using the standar:

<a href="example.html#anchor">

The issues is that when the user clik the link, 1 second white flash appears before the smooth scroolling makes. I dont like this behavior for the "User Experience"

How can I to prevent this?

The JavaScript:

 (function($){

        var jump=function(e)
        {
           if (e){
               e.preventDefault();
               var target = $(this).attr("href");
           }else{
               var target = location.hash;
           }

           $('html,body').animate(
           {
               scrollTop: $(target).offset().top
           },1000, function()
           {
               location.hash = target;
           });

        }

        $('html, body').hide()

        $(document).ready(function()
        {
            $('a[href^=#]').bind("click", jump);

            if (location.hash){
                setTimeout(function(){
                    $('html, body').scrollTop(0).show()
                    jump()
                }, 0);
            }else{
              $('html, body').show()
            }
        });
    })(jQuery) 

Thanks.

Community
  • 1
  • 1
bluufoox
  • 13
  • 3

0 Answers0