使用gsap为背景位置设置动画

时间:2015-12-28 09:59:25

标签: javascript jquery gsap

我有大svg图片描述环境,并试图创建循环,从左到右移动图片:

HTML:

<div class="animation-wrapper" id="scroller" style="position:absolute">
</div>

的CSS:

.animation-wrapper{
    top: -0;
    left: -10000px;
    width: 100%;
    height: 100%;
    @include background-cover("../pictures/animation-background.svg");
    background-position: -10000px 0;
    margin: 0 auto;
}

司法制度评估方案:

var tl = new TimelineMax({repeat:-1});

    headerBackgroundContainer = jQuery(".animation-wrapper");

    function backgroundMoveInitiate()
    {
      tl.to(headerBackgroundContainer, 40, {background_position: 0, ease:Linear.easeNone});
    }

    backgroundMoveInitiate();

没有javascript错误,但根本没有任何反应。我是gsap的新手,请告诉我这里有什么问题?

1 个答案:

答案 0 :(得分:1)

尝试用background_position

替换backgroundPosition
  tl.to(headerBackgroundContainer, 40, {backgroundPosition: 0, ease:Linear.easeNone});

顺便说一句,您也可以将选择器直接传递给TweenMax.to tl.to(".animation-wrapper",...)