TweenLite does not animate

99封情书 提交于 2020-01-03 13:41:09

问题


I am trying to do a simple animation of top-margin using GreenSocks TweenLite for Javascript. I've used the library many times but, for some reason, it's not working this time. Note: The "onComplete" is firing but, no matter what element I use, I cannot animate any CSS properties on HTML elements.

HTML

<div id="GS_PipelineHeadline h2"></div>

JAVASCRIPT

TweenLite.to("#GS_PipelineHeadline h2", 0.5, 
{ 
    "margin-top": 0, 
    ease: "Back.easeOut", 
    onComplete: function () 
    { 
        console.log("Crap"); 
    } 
});

Here is a real quick JSFiddle I created that includes all the CSS, JS and HTML. http://jsfiddle.net/mBPug/

If anyone has any ideas, I would appreciate it!


回答1:


A few things:

  • add the CSS plugin to your fiddle
  • "margin-top" wasn't going to do much, use top instead

.

TweenLite.to("#GS_PipelineHeadline", 0.5, {
    top: 0,
    ease: Back.easeOut,
    onComplete: function () {
        console.log("Crap");
    }
});

http://jsfiddle.net/mBPug/4/



来源:https://stackoverflow.com/questions/20411730/tweenlite-does-not-animate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!