0

我可以像这样更改 left 的值:

$.Velocity.animate(element,
    { left: '100%' }, 0
);

但是我怎样才能用一个变量来动态地改变这个属性,就像这样。

var side = 'left';

 $.Velocity.animate(element,
    properties[side] = '100%', 0
 );

然后我可以动态地将一侧设置为向右或向左。

4

1 回答 1

2
var props = {left: '100%'};
$.Velocity.animate(element,
    props, 0
);

// later just change props:
props = {right: '50%'};
// next animation runs with the new value
$.Velocity.animate(element,
    props, 0
);
于 2014-09-18T10:08:30.733 回答