Created
November 3, 2014 19:25
-
-
Save chrisjordanme/59e7cb13ed21e3ff2b91 to your computer and use it in GitHub Desktop.
Angular Resize Directive. Now with stagnation!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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