(function () { 'use strict'; var myApp = angular.module('streamApp'); myApp.directive('scrolld', function () { return { restrict: 'A', link: function (scope, element, attrs) { var raw = element[0]; var hasScrolled = false; element.bind('scroll', function () { var base = raw.scrollTop + raw.offsetHeight + 1000; if (!hasScrolled) { hasScrolled = true && raw.scrollTop > 500; } if (base > raw.scrollHeight) { scope.$apply(attrs.scrolld); } else { if (hasScrolled && raw.scrollTop < 500) { scope.$apply(attrs.showLess); } } }); } }; }); })();