我在阅读THIS教程并使用他们的代码后尝试使用scrollReveal.js,当我的视口在他们身上时,我仍然无法让我的div淡入。
HTML
<head>
<script src="scrollreveal-master/dist/scrollreveal.min.js"></script>
</head>
<div data-sr>This is the first div</div>
<div data-sr>This is the second div</div>
<div data-sr>This is yet another div</div>
的javascript
new scrollReveal();
当我在我的网页上查看控制台时,它说
&#34; 未捕获的ReferenceError:未定义scrollReveal &#34;
答案 0 :(得分:4)
尝试使用scrollReveal
在滚动上添加动画<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="main">
<div data-sr> one </div>
<div data-sr> two </div>
<div data-sr> three </div>
</div>
<script src="https://unpkg.com/scrollreveal@3.3.2/dist/scrollreveal.min.js"></script>
<script>
// Changing the defaults
window.sr = ScrollReveal({ reset: true });
// Customizing a reveal set
sr.reveal('div', {opacity: 0.9,duration:3000});
</script>
</body>
</html>