Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery animate <object> tag

I have an <object> with an id of 'objectID'.

I can modify its position with .css:

$('#objectID').css({'top': "+=200px"});

But when I use .animate it won't work:

$('#objectID').animate({'top': "+=100px"}, 1000);

or

$('#objectID').animate({top: "10"}, slow);

Or any other variation, which works on divs. Is there a limitation to animating object elements?

like image 840
TrySpace Avatar asked Jul 02 '26 07:07

TrySpace


1 Answers

Since the <object> tag is not supported you can hack out your own animation like this:

var obj = $('#objectID');
var speed = 50;
var distance = 100;

var i = setInterval(function() {
    obj.css({'top': '+=1px' });
    if (parseInt(obj.css('top')) > distance) {
        clearInterval(i);
    }
}, speed);

Change the speed variable to get the animation speed you need.

Here's the jsfiddle.

like image 190
Jivings Avatar answered Jul 04 '26 11:07

Jivings