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
61 lines (57 sloc) 1.43 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, attrs) {
scope.displayImage = function() {
elem[0].setAttribute('src', attrs.lazyImg);
};
}
};
})
.controller('DataCtrl', function($scope) {
$scope.imageUrls = [];
for (var i = 0; i < 20; ++i) {
$scope.imageUrls.push('http://lorempixel.com/g/200/200?_=' + Math.random());
}
});
</script>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
section {
position: absolute;
width: 100%;
height: 80%;
top: 10%;
overflow: scroll;
border-top: 1px solid #000;
border-bottom: 1px solid #000
}
img {
display: block;
width: 200px;
height: 200px;
margin: auto;
}
</style>
</head>
<body ng-app="demo">
<section ng-controller="DataCtrl" scroll-container="global">
<img ng-repeat="imageUrl in imageUrls" lazy-img="{{imageUrl}}" scroll-trigger="displayImage()" alt="some image">
</div>
</body>
</html>
You can’t perform that action at this time.