gpt4 book ai didi

css - 如何在用户滚动查看时设置动画

转载 作者:行者123 更新时间:2023-11-28 13:55:16 26 4
gpt4 key购买 nike

我已经开始使用 ReactJS 构建一个网站,我想在 View 滚动到时将 div 元素设置为动画。

我已经使用 CSS 关键帧来添加这样的动画;

.animateMe {
animation: IntroWelcomeImageAnimation 3s 0.2s forwards cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes IntroLeftAnimation {
0% {
opacity: 0;
transform: translateX(-200px)
}
100% {
opacity: 1;
transform: translateY(0px)
}
}

@keyframes IntroRightAnimation {
0% {
opacity: 0;
transform: translateX(200px)
}
100% {
opacity: 1;
transform: translateY(0px)
}
}

@keyframes IntroWelcomeImageAnimation {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

JS文件

import React from 'react'
import '../../layout/intro.css';


const IntroPage = () => {
return (
<section className="Intro-Page">
<div className="animateme">
</div>
</section>
)
}

export default IntroPage

但是问题是动画只在页面加载时出现,元素加载时也是如此。我怎样才能让他们在不使用 JQuery 的情况下过渡到 ScrollView ?

最佳答案

看看这个图书馆 https://www.react-reveal.com/

滚动时可以触发很多动画

关于css - 如何在用户滚动查看时设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58712290/

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