I got this background image slider thing working in chrome and safari, but it doesnt do anything in firefox. any help?
$(function(){
var image= ".main-content";
var button_left= "#button_left";
var button_right= "#button_right";
var animation= "easeOutQuint";
var time= 800;
var jump= 800;
var action= 0;
$(button_left).click(function(){
right();
});
$(button_right).click(function(){
left();
});
$(document).keydown(function(event){
if(event.keyCode == '37'){
right();
}
});
$(document).keydown(function(event){
if(event.keyCode == '39'){
left();
}
});
function left(){
if(action == 0){
action= 1;
$(image).animate({backgroundPositionX: '-='+jump+'px'}, {duration: time, easing: animation});
setTimeout(anim, time);
}
}
function right(){
if(action == 0){
action= 1;
$(image).animate({backgroundPositionX: '+='+jump+'px'}, {duration: time, easing: animation});
setTimeout(anim, time);
}
}
function anim(){
action= 0;
}
});
I also tried this but it also does nothing
$(image).animate({backgroundPosition: '500px 0px'}, 800);
This code works well for me with jQuery 1.8.1 and Firefox, i had some issues getting Prydie's example to work:
http://nelsonwells.net/2012/08/using-bgpos-js-with-jquery-18/
here try this for background animation
Call to it like this,
The code posted by magiconair no longer works with jQuery 1.8. Here is a patched version that doesn't use the depreciated $.curCSS() method.
The version above doesn't work with jQuery 1.6.1. This one does.
Here an Update of the solution from Prydie (for jQuery 1.80 and higher).
It handle the case of "+=" and "-=" values :
Note: you must use the others methods from the solution of Prydie to make it works.
sample of use :