Skip to content

Instantly share code, notes, and snippets.

@chrisjordanme
Created November 3, 2014 19:25
Show Gist options
  • Save chrisjordanme/59e7cb13ed21e3ff2b91 to your computer and use it in GitHub Desktop.
Save chrisjordanme/59e7cb13ed21e3ff2b91 to your computer and use it in GitHub Desktop.
Angular Resize Directive. Now with stagnation!
angular.module('your-module-name', [])
.directive('onResize', ['$window', function ($window) {
return {
link: function (scope, el, attrs) {
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
angular.element($window).on('resize', function () {
delay(function () {
getWinSize($win.innerWidth());
if ($win.innerWidth() === 980) { // or whatever
//alert(980);
}
}, 500);
});
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment