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/