JSFiddle - React, Tailwind, and code Playground

by marcosfromero

HTML

<script src="http://imakewebthings.github.com/jquery-waypoints/waypoints.min.js"></script>
<img id="first" src="" width="364" height="126" deferred="http://www.google.com/images/logos/ps_logo2.png" />
<div style="height: 500px; ">Some vertical space. Scroll to the bottom</div>
<img id="second" src="" width="364" height="126" deferred="http://www.google.com/images/logos/ps_logo2.png" />

JavaScript

$('img').waypoint(function(event, direction) {
    this.src = this.getAttribute('deferred');
    console.log('Loading', this.id, 'image');
}, {
    triggerOnce: true,
    offset: function() {
        return $.waypoints('viewportHeight') - $(this).height();
    }
})