Skip to content

Instantly share code, notes, and snippets.

@dgieselaar
Last active August 29, 2015 14:07
Show Gist options
  • Save dgieselaar/850df171752558f81200 to your computer and use it in GitHub Desktop.
Save dgieselaar/850df171752558f81200 to your computer and use it in GitHub Desktop.
<div class="scrollable" coen-scroll>
<ul class="actual-menu" data-ng-show="coenScroll.getScroll()>100">
</ul>
</div>
<script type="text/javascript">
angular.module('coen')
.directive('coenScroll', [ '$parse', function ( $parse ) {
return {
controller: [ '$scope', '$element', '$attrs', function ( $scope, $element, $attrs ) {
var ctrl = {};
ctrl.getScroll = function ( ) {
var scrollPosition = 0; //compute
return scrollPosition;
};
$element.bind('scroll', function ( ) {
if($attrs.coenScroll) {
$parse($attrs.coenScroll)($scope, { $scroll: ctrl.getScroll() });
}
});
return ctrl;
}],
controllerAs: 'coenScroll'
}
}]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment