对函数的第二次调用返回Uncaught TypeError:#####不是函数

时间:2016-06-03 11:09:57

标签: jquery function typeerror

我在JS / jQuery上没用,而且还有很多其他的代码和动画都不容易分享,但是有人能让我知道为什么这一切都能正常工作直到它到达最后wordpressAnim();

wordpressAnim();的第一次调用工作正常但是当它再次调用它时我收到错误:

  

未捕获的TypeError:wordpressAnim不是函数

function magentoComplete(){
    console.log("Magento COMPLETE");
    magentoContainer.hide();
    wordpressAnim();
}

function wordpressComplete(){
    console.log("Wordpress Complete");
    wordpressAnim.hide();
    woocommerceAnim();
}

function wooComplete(){
    console.log("Woocommerce Complete");
    wooContainer.hide();
    wordpressAnim();
}

抱歉,以前没有添加过。这是wordpressAnim();函数:

var wordpress = $('.wordpress_anim'),
wordpressAnim;

function wordpressAnim(){

var tlWordpressVisible = new TimelineLite
    tlWordpressSetup = new TimelineLite
    wordpressAnim = $('.wordpress_anim'),
    wordpressText1 = $('.wordpress_anim .text1'),
    wordpressText2 = $('.wordpress_anim .text2'),
    wordpressPercent1 = $('.wordpress_anim .percent1'),
    wordpressPercent2 = $('.wordpress_anim .percent2'),
    wordpressCircle_front_89 = $('.wordpress_anim .circle_front_89'),
    wordpressCircle_front_50 = $('.wordpress_anim .circle_front_50'),
    wordpressPercent1Number = $('.wordpress_anim .percent1Number'),
    wordpressPercent2Number = $('.wordpress_anim .percent2Number'),
    wordpressCircle_back = $('.wordpress_anim .circle_back'),
    wordpressLogo = $('.wordpress_anim .wordpress'),
    wordpressCounter = { var: 0 },
    tlWordpress_anim = new TimelineMax;

tlWordpressVisible.set("circle,polygon,polyline,line,polygon,path, rect", {visibility:"visible"});
tlWordpressSetup.set(".wordpress_anim .percent2, .wordpress_anim .text2", {visibility:"hidden"});

tlWordpress_anim
    .to(wordpressCounter, 3.5, {
        var: 89, 
        onUpdate: function () {
            $(wordpressPercent1Number).html(Math.ceil(wordpressCounter.var));
        },  
        ease:Power3.easeInOut
    })
    .from(wordpressLogo, 1, { y:-50, opacity:0, ease:Power3.easeInOut}, '-=3.5')
    .from(wordpressCircle_back, 0.5, { opacity:0, ease:Power3.easeInOut }, '-=3.5')
    .from(wordpressText1, .5, { y:10, opacity:0, ease:Power3.easeInOut}, '-=2.25')
    .from(wordpressCircle_front_89, 1.5, { drawSVG:"0 0", ease:Power3.easeInOut}, '-=2')
    .to(wordpressText1, .5, { y:200, opacity:0, ease:Power3.easeInOut}, 9)
    // Start second WordPress Anim
    .to(wordpressPercent1, .5, { opacity:0, ease:Power3.easeInOut}, '-=.25')
    .to(wordpressCircle_front_89, .5, { opacity:0, ease:Power3.easeInOut}, '-=.5')
    .set(wordpressPercent2, {visibility:"visible"})
    .set(wordpressText2, {visibility:"visible"})
    .set(wordpressCounter, {
        var: 0
    })
    .to(wordpressCounter, 1.5, {
        var: 50, 
        onUpdate: function () {
            $(wordpressPercent2Number).html(Math.ceil(wordpressCounter.var));
        },  
        ease:Power3.easeInOut
    })
    .from(wordpressText2, .5, { y:10, opacity:0, ease:Power3.easeInOut}, '-=1.5')
    .from(wordpressCircle_front_50, 1.5, { drawSVG:"0 0", ease:Power3.easeInOut}, '-=1.5')

    .to(wordpressAnim, .5, { y:200, opacity:0, ease:Power3.easeInOut}, 18)
    .to(wordpressAnim, .1, { opacity:0, ease:Power3.easeInOut, onComplete: wordpressComplete});

}

1 个答案:

答案 0 :(得分:1)

我认为这可能是由于一个名为wordpressAnim的变量和一个名为function wordpressAnim()的函数

您可以尝试将该功能重命名为wordpressAnimFunc(),并尝试使用此功能吗?