Created
October 21, 2014 16:04
-
-
Save soluml/270b2a9458af79ee8c4d to your computer and use it in GitHub Desktop.
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
//Assumes jQuery and Angular | |
$(window).resize((function() { | |
var timer; | |
return function(e) { | |
if(timer) clearTimeout(timer); | |
timer = setTimeout(function() { $rootScope.$broadcast('window-resize', e); }, 250); | |
}; | |
}())); | |
$scope.$on('window-resize', function(ngEvent, jQEvent) { | |
console.log('WINDOW RESIZED'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bind's to window's resize DOM event. Wait's until resizing is finished (250ms) before calling. Triggers an Angular event that can be bound in scope and passes along with jQuery event for full flexibility in your controller/directive's scope.