【问题标题】:GSAP timelineMax error, cannot read property 'repeat' of undefinedGSAP timelineMax 错误,无法读取未定义的属性“重复”
【发布时间】:2015-06-10 01:40:37
【问题描述】:

我正在尝试使用 GSAP 和 scrollMagic 创建一个简单的 timelineMax,但出现以下错误。一切对我来说都是正确的,所以我不理解这个错误。

Uncaught TypeError: Cannot read property 'repeat' of undefined
d.to @ TweenMax.min.js:14
(anonymous function) @ app.js:12

第 12 行是下面的.to("#parallax1 > div", {y: "80%", ease: Linear.easeNone});

代码如下:

// init controller
    var controller = new ScrollMagic.Controller({globalSceneOptions: {triggerHook: "onEnter", duration: "200%"}});

    // build scenes
    // build tween1
    var tween1 = new TimelineMax();
        tween1.to("#parallax1 > div", {y: "80%", ease: Linear.easeNone});   

    var scene = new ScrollMagic.Scene({triggerElement: "#parallax1"})
                    .setTween(tween1)
                    .addIndicators()
                    .addTo(controller);

(我知道该补间中没有持续时间参数,但如果您查看http://janpaepke.github.io/ScrollMagic/examples/advanced/parallax_sections.html,您会发现他们的 setTween 上没有持续时间参数,并且效果很好)。

【问题讨论】:

    标签: javascript gsap scrollmagic


    【解决方案1】:

    您缺少 duration 参数:

    TweenMax.to(element, duration, {property: value});.

    【讨论】:

    • 嗨,Tahir,我知道看起来是这样,但是如果您查看janpaepke.github.io/ScrollMagic/examples/advanced/…,您会发现他们的setTween 上没有持续时间参数,它工作得很好.setTween("#parallax1 > div", {y: "80%", ease: Linear.easeNone})。这和timelineMax有什么区别? timelineMax 是否总是需要一个持续时间参数?
    • Tahir,从文档看来你是对的,缺少 .setTween 上的补间持续时间只是 1 秒持续时间的简写,也许这个简写不适用于 TimelineMax。嗯...// short hand to add a TweenMax.to() tween for 1 second // this is useful, when the scene has a duration and the tween duration isn't important anyway scene.setTween("obj3", {y: 100}); [参考链接](scrollmagic.io/docs/animation.GSAP.html#Scene.setTween) 无论如何,添加持续时间参数后它现在正在工作。我想知道如何才能获得更好的错误消息?
    • 谁能解释一下这个选择器是什么意思 parallax1 > div ?里面的< 是什么意思?
    • 是的,如您所见,setTweenScrollMagic 提供的实用程序,可以选择完全省略duration 参数。 [Link]。是的 TweenMax / TweenLite / TimelineLite / TimelineMax 所有这些都需要一个 duration 值才能使用。 [Link] 和 [Link]。
    • > 在选择器中表示直接后代,并且有许多类型的 css 选择器可用。 [Link]、[Link]、[Link]、[Link] & [Link]。
    猜你喜欢
    • 2016-03-21
    • 2018-07-25
    • 1970-01-01
    • 2021-02-25
    • 2019-08-04
    • 1970-01-01
    • 2020-10-15
    • 2021-07-28
    相关资源
    最近更新 更多