【问题标题】:Velocity JS set a property dynamicallyVelocity JS 动态设置属性
【发布时间】:2014-09-18 18:08:30
【问题描述】:

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

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

但是如何使用变量动态更改该属性,例如这样。

var side = 'left';

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

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

【问题讨论】:

  • dynamically set 你的意思是while animation is running??
  • 不,在动画之前,基本上我可以决定它从屏幕的哪一侧开始动画,完整的动画有反弹效果。
  • velocity.animate()jQuery.animate() 的替代品,所以我假设同样的规则适用:stackoverflow.com/questions/14693113/…

标签: javascript velocity.js


【解决方案1】:
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
);

【讨论】:

    猜你喜欢
    • 2021-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-18
    • 1970-01-01
    • 1970-01-01
    • 2019-03-07
    • 2017-05-20
    相关资源
    最近更新 更多