1

I've managed to make a function that takes a random number of the page (width & height) and scrolls to it. This works perfectly in Firefox (smooth scrolling and diagonal) but when trying to do this in Safari it only scrolls horizontally.

When doing this in Chrome it works however it lags VERY much. I'm scrolling over pictures, is there any way to make this smoother?

Update: After testing manual scrolling in safari I see that the page is laggy there too. Its flickering and stutters...

This is my code:

$('#nav').bind('click', function(e){
    e.preventDefault();

    var bodyHeight = $('body').height() + 1;
    var bodyLeft = $('body').width() + 1;
    var top = Math.floor(Math.random()* bodyHeight)
    var left = Math.floor(Math.random()* bodyLeft)


    $('html, body').animate({
            scrollTop: top,
            scrollLeft: left
    }, 1000, 'swing');
})

Live demo: http://www.nicesprites.se/patrik_berg/

1 Answer 1

1

You should use the latest Jquery version and you will be fine.

Use e.g.http://code.jquery.com/jquery-latest.min.js

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, it fixes the diagonal scrolling but not the lagging: Have reuploaded the live demo so you can see my problem. Thx!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.