【问题标题】:JQuery infinite animationjQuery无限动画
【发布时间】:2015-05-14 15:36:50
【问题描述】:

我尝试做一个无限的 JQuery 动画,但是这个,只做 1 个动画然后停止....我尝试使用 setTimeout 来解决它,但它不起作用。 你知道为什么吗?

<div class="row">
    <div id="homeAnimation">
        <div id="A">soins</div>
        <div id="B">formation</div>
        <div id="C">contact</div>
    </div>
</div>

function anim( selector, firstDelay) {
console.log(selector);
$(selector).animate({
    'margin-left':'100%'
}, 0).delay(firstDelay)
.animate({
            'margin-left': '50%',
            'transform: scale':'2'
        }, 1000).delay(2000)
        .animate({
            'margin-left': '-7%',
            'transform: scale':'1'
        }, 1000);
        return;
    }
    setTimeout( anim("#homeAnimation #A", 0 * 8000), 10000);
    setTimeout( anim("#homeAnimation #B", 1 * 8000), 10000);
    setTimeout( anim("#homeAnimation #C", 2 * 8000), 10000);`

【问题讨论】:

标签: jquery


【解决方案1】:

我让它无限:

function anim( selector, firstDelay) {
    console.log(selector);
    $(selector).animate({
        'margin-left':'100%'
    }, 0).delay(firstDelay)
    .animate({
                'margin-left': '50%',
                'transform: scale':'2'
            }, 1000).delay(2000)
            .animate({
                'margin-left': '-7%',
                'transform: scale':'1'
            }, 1000);
            return;
        }
        setTimeout( anim("#homeAnimation #A", 0 * 8000), 100000);
        setTimeout( anim("#homeAnimation #B", 1 * 8000), 100000);
        setTimeout( anim("#homeAnimation #C", 2 * 8000), 100000);

【讨论】:

  • 对不起,它对我不起作用 更改为 100s 没有做任何事情,奇怪的是该函数只调用了一次
猜你喜欢
  • 2013-04-27
  • 2016-02-08
  • 2011-06-10
  • 2012-02-09
  • 1970-01-01
  • 2017-02-21
  • 1970-01-01
  • 2019-08-24
  • 1970-01-01
相关资源
最近更新 更多