Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (48 sloc) 1.19 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Scroll Trigger</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular.js"></script>
<script src="../dist/scroll-trigger.js"></script>
<script>
angular.module('demo', ['scroll-trigger'])
.directive('lazyImg', function(ScrollTrigger) {
return {
restrict: 'A',
scope: true,
link: function(scope, elem) {
scope.displayImage = function(randint) {
elem[0].setAttribute('src', 'http://lorempixel.com/g/200/200?_=' + randint);
};
}
};
})
.run(function() {
for (var i = 0; i < 5; ++i) {
var img = document.createElement('img')
img.setAttribute('lazy-img', true);
img.setAttribute('scroll-trigger', 'displayImage(' + Math.random() + ')');
document.body.appendChild(img);
}
});
</script>
<style>
div {
width: 200px;
height: 1000px;
}
.placeholder {
background-color: #000;
}
img {
display: block;
width: 200px;
height: 200px;
}
</style>
</head>
<body ng-app="demo">
<div class="placeholder"></div>
</body>
</html>
You can’t perform that action at this time.