gpt4 book ai didi

javascript - 如何在 GSAP 和 ScrollMagic 中为底部和不透明度属性设置动画?

转载 作者:太空宇宙 更新时间:2023-11-04 08:29:26 25 4
gpt4 key购买 nike

使用以下代码,我可以错开动画位置并使文本淡入。但我想完成的是移动、淡入、然后将所有副本淡入滚动结束时为 0。所以移动工作正常。我只想要相同的 <p>标签淡入然后在滚动结束时退出。

// init controller to hold all commands/animations
const controller = new ScrollMagic.Controller({ addIndicators: true });

const tween1 = TweenMax
.staggerTo('#parallax p', 1, {
bottom: $('#parallax').height(),
opacity: 1,
}, 0.06);

// All commands/animations live in a scene
new ScrollMagic.Scene({
// Element to watch
triggerElement: '#parallax',
// Point at which animation starts, default is center of screen
triggerHook: 0, // 1 onEnter, .5 onCenter (Defualt), 0 onLeave
})
.setPin('#parallax')
.setTween(tween1)
.duration('100%') // Percentage of full screen or hard-wired number of pixels
.addIndicators({ name: 'FADES' }) // Indicators marked on screen
.addTo(controller); // Add this scene to controller

附带问题:如果动画是通过 ScrollMagic 滚动的,那么 1 是什么?对于以下行:.staggerTo('#parallax p', 1, {

编辑:更合适CodePen added

最佳答案

还有更像这样的吗? https://codepen.io/motionimaging/pen/155bf1892710fb95dcc81ddb7201adb0/

// init controller to hold all commands/animations
const controller = new ScrollMagic.Controller({ addIndicators: true });

var timeline = new TimelineMax();
var tween1 = TweenMax.staggerFromTo("#two p", 1, {bottom: 0},{bottom: $('#two').height()}, 0.1);

var tween2a = TweenMax.staggerTo("#two p", 0.5,{ opacity: 1 }, 0.1);

var tween2b = TweenMax.staggerTo("#two p", 0.35,{ opacity: 0 }, 0.1);

timeline.add(tween1, 0)
.add(tween2a, 0)
.add(tween2b, 0.5);

new ScrollMagic.Scene({
triggerElement: "#two",
triggerHook: 0,
})
.setTween(timeline)
.setPin("#two")
.duration("200%")
.addIndicators({ name: "FADES" })
.addTo(controller);

关于javascript - 如何在 GSAP 和 ScrollMagic 中为底部和不透明度属性设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44893825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com