initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
24
static/js/directives/onresize.js
Normal file
24
static/js/directives/onresize.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Adds an onresize event attribute that gets invokved when the size of the window changes.
|
||||
*/
|
||||
angular.module('quay').directive('onresize', function ($window, $parse, $timeout) {
|
||||
return function (scope, element, attr) {
|
||||
var fn = $parse(attr.onresize);
|
||||
|
||||
var notifyResized = function() {
|
||||
// Angular.js enforces only one call to $apply can run at a time.
|
||||
// Use $timeout to make the scope update safe, even when called within another $apply block,
|
||||
// by scheduling it on the call stack.
|
||||
// See docs: https://docs.angularjs.org/error/$rootScope/inprog
|
||||
$timeout(function () {
|
||||
fn(scope);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
angular.element($window).on('resize', null, notifyResized);
|
||||
|
||||
scope.$on('$destroy', function() {
|
||||
angular.element($window).off('resize', null, notifyResized);
|
||||
});
|
||||
};
|
||||
});
|
Reference in a new issue