简体   繁体   English

基本动画效果-我应该使用jQuery还是HTML5 Canvas?

[英]Basic Animation effect - should I use jQuery or HTML5 Canvas?

I'm currently working on a very basic animation for my web page at the moment. 目前,我目前正在为我的网页制作非常基本的动画。

  1. I'd like to move one element ( .item1 ) from the bottom into a container. 我想将一个元素( .item1 )从底部移到一个容器中。

  2. Once this move is completed, I would like to move a 2nd item ( .item2 ) from the left into the middle of the container. 一旦完成此移动,我想将第二个项目( .item2 )从左侧移动到容器的中间。

In time, these div blocks will be replaced with images. 这些div块将及时替换为图像。

DEMO: http://jsfiddle.net/9rE6Z/3/embedded/result/ 演示: http : //jsfiddle.net/9rE6Z/3/e​​mbedded/result/

What would be the best approach to doing this? 这样做的最佳方法是什么? Is it possible to use jQuery or should I be looking at HTML5 Canvas for this? 是否可以使用jQuery,还是应该为此使用HTML5 Canvas?

I'm very new to both areas and would really appreciate some pointers with this :-) 我对这两个领域都很陌生,对此我将不胜感激:-)

Many thanks :-D 非常感谢:-D

My HTML: 我的HTML:

<div style="width:100%;background:white">

    <div style="height:450px;width:980px;margin:0 auto;background:white;border:1px solid #000">

    </div>

</div>

<div class="item1" style="position:absolute;top:450px;left:50%;width:100px;height:100px;background:black"></div><!-- ease this up from bottom -->
<div class="item2" style="position:absolute;top:0;left:0;width:100px;height:100px;background:blue"></div><!-- ease this in from left -->

Do you want something like this? 你想要这样的东西吗? http://jsfiddle.net/9rE6Z/4/ http://jsfiddle.net/9rE6Z/4/

var i1 = $("#item1"),
    i2 = $("#item2"),
    wrap = $("#wrap");

i1.animate({
    "bottom": 0,
    "opacity": 1
}, 700, function () {
    i2.animate({
        "left": 0,
        "opacity": 1
    }, 700);
});

I changed your HTML mark up a bit, too make it more logical. 我更改了您的HTML标记,也使其更加合乎逻辑。

<div id="wrap">
    <div id="inner-wrap">
        <div id="item1"></div>
        <div id="item2"></div>
    </div>
</div>

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

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