Reputation: 120
I am trying to implement a one page slider to a homepage and I have it working in FF and IE but not in safari or Chrome..
This is the code I am using for the slider..
//sliding content
$("#main-nav a").click(function(){
var target = $(this).attr("href");
$("html, body").stop().animate({
scrollLeft: $(target).offset().left,
}, 1200);
});
The url of the site in question is http://stable.dev.lemon-fresh.co.uk
Upvotes: 1
Views: 1157
Reputation: 206593
Got it!
use position
instead of offset
:
scrollLeft: $(target).position().left
And remove the comma ',
' as you are not listing any other properties.
$("#main-nav a").click(function(){
var target = $(this).attr("href");
$("html, body").stop(1).animate({ // used : .stop(1) (same as .stop(true) )
scrollLeft: $(target).position().left // position instead of offset
}, 1200);
});
And another suggestion:
As I have seen, on fast-clicking on your links - all the animations gets cached resulting in an annoying waiting to get to the right place. A nice trick to remove (clear) that animation queue is to use .stop(1)
try it out!
Upvotes: 1