mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Drag drop binding expression watcher was expensive, removed watcher after first eval, seems to still work
This commit is contained in:
parent
c6e57d64d7
commit
dc382a6df7
@ -124,6 +124,4 @@ function (angular, app, _) {
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
11
src/vendor/angular/angular-dragdrop.js
vendored
11
src/vendor/angular/angular-dragdrop.js
vendored
@ -257,9 +257,11 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
|
||||
require: '?jqyouiDroppable',
|
||||
restrict: 'A',
|
||||
link: function(scope, element, attrs) {
|
||||
var dragSettings, zIndex;
|
||||
// grafana change, remove watcher after first evaluation
|
||||
var dragSettings, zIndex, removeWatcher;
|
||||
var updateDraggable = function(newValue, oldValue) {
|
||||
if (newValue) {
|
||||
removeWatcher();
|
||||
dragSettings = scope.$eval(element.attr('jqyoui-draggable')) || [];
|
||||
element
|
||||
.draggable({disabled: false})
|
||||
@ -283,7 +285,7 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
|
||||
element.draggable({disabled: true});
|
||||
}
|
||||
};
|
||||
scope.$watch(function() { return scope.$eval(attrs.drag); }, updateDraggable);
|
||||
removeWatcher = scope.$watch(function() { return scope.$eval(attrs.drag); }, updateDraggable);
|
||||
updateDraggable();
|
||||
}
|
||||
};
|
||||
@ -292,8 +294,11 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
|
||||
restrict: 'A',
|
||||
priority: 1,
|
||||
link: function(scope, element, attrs) {
|
||||
// grafana change, remove watcher after first evaluation
|
||||
var removeWatcher;
|
||||
var updateDroppable = function(newValue, oldValue) {
|
||||
if (newValue) {
|
||||
removeWatcher();
|
||||
element
|
||||
.droppable({disabled: false})
|
||||
.droppable(scope.$eval(attrs.jqyouiOptions) || {})
|
||||
@ -319,7 +324,7 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
|
||||
}
|
||||
};
|
||||
|
||||
scope.$watch(function() { return scope.$eval(attrs.drop); }, updateDroppable);
|
||||
removeWatcher = scope.$watch(function() { return scope.$eval(attrs.drop); }, updateDroppable);
|
||||
updateDroppable();
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user