[SOLVED] Dom7 animate with % as unit

hello, i am trying to assign % as unit for css prop ‘top’ but Dom7.animate keeps converting it to px .

this.$$(’#logo’).animate({
‘opacity’: 1,
‘top’: 50%,
});

do we have any way to assign such unit, thx .

You need to wrap value with quotes:

top: '50%'

Thanks for reply … i did wrap the value to be ‘50%’ but still converted to ‘50px’ .

Sorry, just checked it. No, it is not possible. Because it automatically gets animation unit from its initial style which is not really possible to retreive in percents. So just use transition instead.

In CSS:

#logo {
  transition: 300ms;
}

and then just

this.$$('#logo').css({
'opacity': 1,
'top': '50%',
});

Thanks again … it did the task for me .