【问题标题】:how can i throttle animations, e.g. set them based on pinch gesture scale我如何限制动画,例如根据捏手势比例设置它们
【发布时间】:2014-09-20 05:10:03
【问题描述】:

我正在使用velocity.js 为css 属性设置动画。

$(".list-element).velocity({
        height: "50px"
    }, {
        duration: 250
    })  

我也想根据动态事件将相同的属性更改为相同的目标值。

尤其是捏手势(hammer.js)和滚动。

为此,我需要一些方法来告诉速度我只想要完整动画的一个子集。 例如将其设置为完整动画的 10%。

将整个动画分成 x 个小部分会破坏我认为的缓动。

【问题讨论】:

    标签: javascript jquery-animate velocity.js


    【解决方案1】:

    你的问题很笼统!
    我没有得到你想要的!
    但在 Velocity 中,您可以使用函数而不是某个值,如下所示:

    var step = 10; //consider it's dynamic variable!
    $elm.velocity({
        height: function() {
            return '+='+(step/100)*300+'px';
        }
    },whatEver);
    

    【讨论】:

      猜你喜欢
      • 2019-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-07
      • 2016-11-24
      • 1970-01-01
      相关资源
      最近更新 更多