-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Tips (v2.x)
Since we’re using data-
attributes, we want to specify an HTML5 doctype before our opening html
tag. Without this, you may experience odd behavior (#169).
<!DOCTYPE html>
<html>
<body></body>
</html>
The nature of JavaScript, is that it runs after the request payload has returned… and often, after the browser has already begun rendering content. This means, your elements may be visible momentarily before scrollReveal can run and apply the initial styles.
<!DOCTYPE html>
<html>
<head>
<style>
[data-sr] {
visibility: hidden;
}
</style>
</head>
<body>
<div data-sr> I will load hidden! </div>
</body>
</html>
Note: It’s important to emphasize that [data-sr] { visibility: hidden; }
should be at the top of your document, NOT inside a CSS file. Otherwise, your elements may still be visible momentarily while your site loads.
ScrollReveal supports 3d rotations; they work out of the box, but you may want to emphasize the 3d effect by applying a perspective
property on a containing element.
<!DOCTYPE html>
<html>
<head>
<style>
.container {
perspective: 1000px;
}
</style>
</head>
<body>
<div class="container">
<div data-sr="spin 60deg, roll 10deg"> Weeeee! </div>
<div data-sr="spin 45deg, roll 10deg"> Waahoo! </div>
<div data-sr="spin 30deg, roll 10deg"> Yippie! </div>
</div>
</body>
</html>