Reputation: 127
I have an issue with a jquery image slide plugin i'm working on where the images scroll left creating the slideshow. IE and FireFox work fine but Safari/Chrome(WebKit) just wont work.
This the call in question
$(".nav li").live("click", function () {
if (lastSelected != null) $(lastSelected).removeClass("selected");
$(this).addClass("selected");
place = parseInt($(this).text());
if (place > last) {
offset = parseInt(place - last);
direction = "-=";
}
else {
offset = parseInt(last - place);
direction = "+=";
}
// this is where it only works for IE and FF
$(".slideshow img").each(function () {
$(this).animate({
left: direction + (offset * imageWidth) + "px"
});
});
// Am I doing something wrong hmm?
reset = true;
last = place;
lastSelected = $(this);
}).css("cursor", "pointer");
Upvotes: 1
Views: 1182
Reputation: 127
So I have been doing some debugging an have found that the offset * imageWidth stays 0 in Chrome!
Solution found:
These two sources help fix the "jQuery get image height or width returns 0 problem" which was the initial problem. I am now using the fix found in the first solution above and that works fine.
Upvotes: 0
Reputation: 17576
what is this lastSelected
are you sure
$(lastSelected).removeClass("selected");
is working ???
because
lastSelected is an `object` not an attribute
try this (assume you have an id attribute)
lastSelected = $(this).attr('id');
and
if (lastSelected != null) $('#'+lastSelected).removeClass("selected");
Upvotes: 1