首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SuperScrollOrama和TweenMax淡入淡出滚动

SuperScrollOrama和TweenMax淡入淡出滚动
EN

Stack Overflow用户
提问于 2014-01-28 03:50:11
回答 1查看 2.2K关注 0票数 0

我有一系列的彩色DIVs,当你向下滚动页面时,我会尝试淡入和淡出。

我的div设置很简单:

代码语言:javascript
复制
<div class="wrapper">
        <div id="content" class="clearfix">
            <div class="box alpha"></div>
            <div class="box beta"></div>
            <div class="box gamma last"></div>
            <div class="box delta"></div>
            <div class="box epsilon"></div>
            <div class="box zeta last"></div>
        </div>
    </div>

下面是我的superscrollorama/tweenmax脚本:

代码语言:javascript
复制
var controller = $.superscrollorama();
controller.addTween('.box.alpha', TweenMax.from( $('.box.alpha'), 1, {css:{opacity: 1} ,ease:Quad.easeInOut}), 400);
controller.addTween('.box.alpha', TweenMax.to( $('.box.alpha'), 1, {css:{opacity: .2}}), 1600);
controller.addTween('.box.beta', TweenMax.from( $('.box.beta'), 1, {css:{opacity: .2}}), 1600);
controller.addTween('.box.beta', TweenMax.to( $('.box.beta'), 1, {css:{opacity: 1} ,ease:Quad.easeInOut}), 2400);
controller.addTween('.box.gamma', TweenMax.from( $('.box.gamma'), 1, {css:{opacity: .2}}), 2400);
controller.addTween('.box.gamma', TweenMax.to( $('.box.gamma'), 1, {css:{opacity: 1} ,ease:Quad.easeInOut}), 3200);
controller.addTween('.box.delta', TweenMax.from( $('.box.delta'), 1, {css:{opacity: .2}}), 3200);
controller.addTween('.box.delta', TweenMax.to( $('.box.delta'), 1, {css:{opacity: 1} ,ease:Quad.easeInOut}), 4000);
controller.addTween('.box.epsilon', TweenMax.from( $('.box.epsilon'), 1, {css:{opacity: .2}}), 4000);
controller.addTween('.box.epsilon', TweenMax.to( $('.box.epsilon'), 1, {css:{opacity: 1} ,ease:Quad.easeInOut}), 4800);
controller.addTween('.box.zeta', TweenMax.from( $('.box.zeta'), 1, {css:{opacity: .2}}), 4800);
controller.addTween('.box.zeta', TweenMax.to( $('.box.zeta'), 1, {css:{opacity: 1} ,ease:Quad.easeInOut}), 5600);

当你向下滚动页面时,所有东西都会淡入,但我想要一个框淡出,而下一个框则淡入,我可能这样做是错误的,但我找不到大量的文档。

下面是我正在做的事情:http://emptywalrus.com/scroll/

EN

回答 1

Stack Overflow用户

发布于 2014-01-28 03:54:04

您需要创建一个Timeline。下面是我在我的一个项目中做的相同的事情的示例:

代码语言:javascript
复制
controller.addTween(
    '#the-problem',
    (new TimelineLite())
        .append([
            TweenMax.fromTo($('#the-problem .animation-heading'), 1,
                { delay: 0.3, css: { right: -1500 }, ease: Expo.easeInOut },
                { delay: 0.3, css: { right: 0 }, ease: Expo.easeInOut }),
            TweenMax.fromTo($('#the-problem .animation-text'), 1,
                { delay: 0.1, css: { right: -1500 }, ease: Expo.easeInOut },
                { delay: 0.1, css: { right: 0 }, ease: Expo.easeInOut }),
            TweenMax.fromTo($('#the-problem .animation-image'), 1,
                { delay: 0.1, css: { left: -1500 }, ease: Expo.easeInOut },
                { delay: 0.1, css: { left: 0 }, ease: Expo.easeInOut })
        ]), 700, -400);

controller.addTween(
    '#the-solution',
    (new TimelineLite())
        .append([
            TweenMax.fromTo($('#the-solution .animation-heading'), 1,
                { delay: 0.3, css: { left: -1500 }, ease: Expo.easeInOut },
                { delay: 0.3, css: { left: 0 }, ease: Expo.easeInOut }),
            TweenMax.fromTo($('#the-solution .animation-text'), 1,
                { delay: 0.1, css: { left: -1500 }, ease: Expo.easeInOut },
                { delay: 0.1, css: { left: 0 }, ease: Expo.easeInOut }),
            TweenMax.fromTo($('#the-solution .animation-image'), 1,
                { delay: 0.1, css: { right: -1500 }, ease: Expo.easeInOut },
                { delay: 0.1, css: { right: 0 }, ease: Expo.easeInOut })
        ]), 700, -400);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21390267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档