Skip to content

Instantly share code, notes, and snippets.

View wesleyramalho's full-sized avatar

Wesley Ramalho wesleyramalho

  • São Paulo, Brazil.
View GitHub Profile
<script>
$(window).on("load",function() {
$(window).scroll(function() {
$(".fade").each(function() {
/* Check the location of each desired element */
var objectBottom = $(this).offset().top + $(this).outerHeight();
var windowBottom = $(window).scrollTop() + $(window).innerHeight();
/* If the element is completely within bounds of the window, fade it in */
if (objectBottom < windowBottom) { //object comes into view (scrolling down)
<html>
<head>
<link rel="stylesheet" type="text/css" href="estilo.css">
<link rel="javascript" type="text/javascript" href="script.js">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div>
.fade {
margin: 50px;
padding: 50px;
background-color: lightgreen;
opacity: 1;
}