Drag and drop toElement property in event is null on FF/IE

时间:2017-08-04 12:39:21

标签: javascript angularjs javascript-events drag-and-drop

I have a drag and drop functionality on my angular web page and it works great on Chrome Version 60.0.3112.78 but it does not work on FF 54.0.1 and Microsoft Edge. I noticed that property

event.toElement

does not exist on FF and ME that's why I have my error. Why is it happening?

        var ondrop = function(event) {
            event.preventDefault();

            var from = parseInt(event.dataTransfer.getData('dragElementIndex'));

            var toElement = getItemElement(event.toElement);

            var to = getContainerIndex(toElement);

            if (from !== to && to !== -1) {
                scope.reorder(from, to);
            }

            scope.$apply();
        };

0 个答案:

没有答案