Skip to content

Instantly share code, notes, and snippets.

@soluml
Created October 21, 2014 16:04
Show Gist options
  • Save soluml/270b2a9458af79ee8c4d to your computer and use it in GitHub Desktop.
Save soluml/270b2a9458af79ee8c4d to your computer and use it in GitHub Desktop.
//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');
});
@soluml
Copy link
Author

soluml commented Oct 21, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment