Skip to content

Instantly share code, notes, and snippets.

@snichme
Created October 25, 2013 01:22
Show Gist options
  • Select an option

  • Save snichme/7148054 to your computer and use it in GitHub Desktop.

Select an option

Save snichme/7148054 to your computer and use it in GitHub Desktop.
Scroller service for Angular
(function() {
'use strict';
angular.module('ngExtensionsApp')
.factory('Scroll', function($window, $timeout) {
var wait = 100,
callbacks = [],
timeout_identifier = null;
function onScroll(event) {
$timeout.cancel(timeout_identifier);
timeout_identifier = $timeout(function() {
callbacks.forEach(function(cb) {
cb(event);
});
}, wait);
};
$window.onscroll = onScroll;
return function(cb) {
callbacks.push(cb);
};
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment