简体   繁体   English

jQuery缓动:如何将动画作为一种缓动动画链接在一起?

[英]jQuery easing: How to chain animations together as one easing animation?

I have two animations that I would like to group as one animation so that the easing will carry over and continue into the next animation. 我有两个动画,我想归为一个动画,以便缓动会延续并继续到下一个动画中。 The second animation needs to start after the first one has finished. 第二个动画需要在第一个动画完成后开始。 This is what I have so far, but the easing starts over when the second animation begins (which is what I would have expected). 这是我到目前为止的内容,但是在第二个动画开始时缓动会重新开始(这是我所期望的)。

$progressBar.animate({width: progressBarWidth + '%'}, barAnimationSpeed, 'swing', function(){
    $overGoalBar.animate({width: overGoalBarWidth + '%'}, barAnimationSpeed, 'swing', function(){});
});

Here's an example of how it works right now . 这是它现在如何工作的示例

How can I group these animations into one easing animation? 如何将这些动画分组为一个缓动动画?

If you want to demonstrate dynamically created percentage value of progress bar with easing effect. 如果要演示动态创建的进度条的百分比值具有缓和效果。

I would use server created background Image 我将使用服务器创建的背景图片

ex) Using GD Library in PHP 例)在PHP中使用GD库

and set that image as background of one DIV tag in CSS. 并将该图像设置为CSS中一个DIV标签的背景。

#progressBar { background-img('Dynamically-created-image.jpg'); }

Lastly just animate that one DIV tag once. 最后,只对一个DIV标签进行一次动画处理。

If I have understood you correctly, this idea might work. 如果我正确地理解了您,则此想法可能会起作用。

Here is a great online tool for writing a custom easing function... 这是一个很棒的在线工具,用于编写自定义缓动功能...

http://www.timotheegroleau.com/Flash/experiments/easing_function_generator.htm http://www.timotheegroleau.com/Flash/experiments/easing_function_generator.htm

Also, here is more information in general about easing... you do not need the easing plugin if you have an easing function. 另外,这里是有关放宽的更多常规信息...如果您具有放宽功能,则不需要放宽插件。 From the links contained within, you can see a demo of each and then compare to the easing function behind it... 从其中包含的链接中,您可以看到每个示例的演示,然后将其与后面的缓动功能进行比较...

How can I add aceleration to this jQuery animation? 如何向该jQuery动画添加加速度?

Have you tried using linear ? 您是否尝试过使用linear

$('#progressBar').animate({width: 50 + '%'}, 2500, 'linear', function(){
    $('#overGoalBar').animate({width: 49 + '%'}, 2500, 'linear', function(){});
});

It's note exactly chaining two animations together, but it does smooth it out. 注意将两个动画精确地链接在一起,但是确实可以使它平滑。

http://jsfiddle.net/dkBMA/11/ http://jsfiddle.net/dkBMA/11/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM