Asked by duncanb7
at 2024-12-27 09:06:08
Point:500 Replies:4 POST_ID:828546USER_ID:11059
Topic:
JavaScript;;
I have two questions about Jquery animate function. I would like to move
my background image from -800x to 0px in x-direction within 5 seconds and then
css back to 0px 0px in x-y axis and then move it
from 0 to 460px in y-direction also within 5 seconds for both Firefox and IE7.
Question-1, How can I make it work in y-direction in Firefox? I tried backgroundPositionY in .animate ?
but it faild.
Question-2 Animate "backgroundPosition":"0px" in IE7 that the result is totally different from Firefox.
Actully I can use background-position-x and background-position-y for my expectation for IE7 but
how can I combine it into one for both Firefox and IE7 at the same time or within using same javascript code page ?
I tried to modify the following init() function code from original one, but it failed to meet my expectation.
function init(){
$('#block').animate({"backgroundPosition":"0px","background-position-x":"0px"},{duration:5000,complete:function(){
$('#block').css("background-position","0px 0px");
//$('#block').animate({"backgroundPositionY":"460px"},{duration:5000,complete:function(){}});
}});
}
Please advise
Duncan
my background image from -800x to 0px in x-direction within 5 seconds and then
css back to 0px 0px in x-y axis and then move it
from 0 to 460px in y-direction also within 5 seconds for both Firefox and IE7.
Question-1, How can I make it work in y-direction in Firefox? I tried backgroundPositionY in .animate ?
but it faild.
Question-2 Animate "backgroundPosition":"0px" in IE7 that the result is totally different from Firefox.
Actully I can use background-position-x and background-position-y for my expectation for IE7 but
how can I combine it into one for both Firefox and IE7 at the same time or within using same javascript code page ?
I tried to modify the following init() function code from original one, but it failed to meet my expectation.
function init(){
$('#block').animate({"backgroundPosition":"0px","background-position-x":"0px"},{duration:5000,complete:function(){
$('#block').css("background-position","0px 0px");
//$('#block').animate({"backgroundPositionY":"460px"},{duration:5000,complete:function(){}});
}});
}
Please advise
Duncan
Attachment:animate.htmlskybuild.jpg