Skip to content

Commit

Permalink
New DOM spec introducing passive listeners is causing some Verbose me…
Browse files Browse the repository at this point in the history
…ssages in the console. Quick workaround to disable all the bindings to touch/drag/drop events. Need to be refactored in order to be complaint with the newAPI. More info at:

https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
jquery/jquery-mousewheel#168 (comment)
  • Loading branch information
Xavi Gimenez committed Dec 20, 2017
1 parent 128ca58 commit 28e3ffc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 79 deletions.
50 changes: 5 additions & 45 deletions dist/angular-ui-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@

angular.module('ui.tree')

.controller('TreeNodesController', ['$scope', '$element',
function ($scope, $element) {
.controller('TreeNodesController', ['$scope', '$element', '$timeout',
function ($scope, $element, $timeout) {
this.scope = $scope;

$scope.$element = $element;
Expand Down Expand Up @@ -243,22 +243,11 @@
return $scope.$modelValue.length > 0;
};

$scope.safeApply = function (fn) {
var phase = this.$root.$$phase;
if (phase == '$apply' || phase == '$digest') {
if (fn && (typeof (fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
};

//Called in apply method of UiTreeHelper.dragInfo.
$scope.removeNode = function (node) {
var index = $scope.$modelValue.indexOf(node.$modelValue);
if (index > -1) {
$scope.safeApply(function () {
$timeout(function () {
$scope.$modelValue.splice(index, 1)[0];
});
return $scope.$treeScope.$callbacks.removed(node);
Expand All @@ -268,7 +257,7 @@

//Called in apply method of UiTreeHelper.dragInfo.
$scope.insertNode = function (index, nodeData) {
$scope.safeApply(function () {
$timeout(function () {
$scope.$modelValue.splice(index, 0, nodeData);
});
};
Expand Down Expand Up @@ -1350,50 +1339,21 @@
/**
* Binds the mouse/touch events to enable drag start for this node.
*/
//This is outside of bindDragMoveEvents because of the potential for a delay setting.
//This is outside of bindDragMoveEvents because of the potential for a delay setting.
bindDragStartEvents = function () {
element.bind('touchstart mousedown', function (e) {
//Don't call drag delay if no delay was specified.
if (scope.dragDelay > 0) {
dragDelay.exec(function () {
dragStartEvent(e);
}, scope.dragDelay);
} else {
dragStartEvent(e);
}
});
element.bind('touchend touchcancel mouseup', function () {
if (scope.dragDelay > 0) {
dragDelay.cancel();
}
});
};
bindDragStartEvents();

/**
* Binds mouse/touch events that handle moving/dropping this dragged node
*/
bindDragMoveEvents = function () {
angular.element($document).bind('touchend', dragEndEvent);
angular.element($document).bind('touchcancel', dragEndEvent);
angular.element($document).bind('touchmove', dragMoveEvent);
angular.element($document).bind('mouseup', dragEndEvent);
angular.element($document).bind('mousemove', dragMoveEvent);
angular.element($document).bind('mouseleave', dragCancelEvent);
angular.element($document).bind('keydown', keydownHandler);
};

/**
* Unbinds mouse/touch events that handle moving/dropping this dragged node.
*/
unbindDragMoveEvents = function () {
angular.element($document).unbind('touchend', dragEndEvent);
angular.element($document).unbind('touchcancel', dragEndEvent);
angular.element($document).unbind('touchmove', dragMoveEvent);
angular.element($document).unbind('mouseup', dragEndEvent);
angular.element($document).unbind('mousemove', dragMoveEvent);
angular.element($document).unbind('mouseleave', dragCancelEvent);
angular.element($document).unbind('keydown', keydownHandler);
};
}
};
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-ui-tree.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 28e3ffc

Please sign in to comment.