Reputation: 591
I am developing an application with AngularJS and a component called ngDraggable, but i'm having some trouble with touch events. When a touch event for drag is executed an error is shown on console:
Uncaught TypeError: Cannot read property '0' of undefined ngDraggable.js:118
onlongpress ngDraggable.js:118
(anonymous function) ngDraggable.js:95
I've already tried to debug the code, and the variable evt
does not have the array touches
as it have on the examples codes.
Does anybody have an idea how can I solve this problem?
Below a snippet where the code have problem:
var onlongpress = function(evt) {
if(! _dragEnabled)return;
evt.preventDefault();
element.addClass('dragging');
offset = _privoffset(element);
element.centerX = element[0].offsetWidth / 2;
element.centerY = element[0].offsetHeight / 2;
_mx = (evt.pageX || evt.touches[0].pageX); // <---- This is the line the problem occurs
_my = (evt.pageY || evt.touches[0].pageY);
_mrx = _mx - offset.left;
_mry = _my - offset.top;
if (_centerAnchor) {
_tx = _mx - element.centerX - $window.pageXOffset;
_ty = _my - element.centerY - $window.pageYOffset;
} else {
_tx = _mx - _mrx - $window.pageXOffset;
_ty = _my - _mry - $window.pageYOffset;
}
[...]
Upvotes: 3
Views: 359
Reputation: 591
I just solved the problem.
They just updated the module. Just update the module with the last release and the problem is solved.
Upvotes: 1