JQuery animate <object> tags

I have an objectID <object>with an idobject.

I can change its position with .css:

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

But when I use .animate, this will not work:

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

or

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

Or any other option that works on divs. Is there a restriction on the animation of elements object?

+3
source share
4 answers

Since the tag is <object>not supported, you can crack your own animation as follows:

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 desired animation speed.

Here's the jsfiddle .

+3
source

, , , , : : .

0

css ?

​#objectID{
  position: absolute;
  top: 0px;
  ...
}​

In fact, I believe that it is Objectnot supported for animate(). I was able to use .cssin jsfiddle.

Should be able to use .css(), though: http://jsfiddle.net/mkprogramming/bw9Kb/15/

0
source

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

$('#objectID').animate({top: "10"}, slow); An integer must not be surrounded by quotation marks, but slowmust be surrounded by quotation marks.

This should solve your problem.

0
source

All Articles