I am using native HTML drag'n'drop in my angular app and I found this event flickering problem
This answer doesnt solve my issue, as they are moving the element manualy. I am leaving it on native implementation.
My simplified code:
var app = angular.module('app', []);
app.directive('amDnd', function() {
return {
scope: true,
link: function($scope, $element, $attr) {
var el = $element[0];
el.draggable = true;
el.addEventListener('dragenter', function dragEnter(e) {
console.log($scope.$id, 'dragEnter');
}, false);
el.addEventListener('dragleave', function dragEnter(e) {
console.log($scope.$id, 'dragleave');
}, false);
}
};
});
div[am-dnd] {
border: 2px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
<div am-dnd>
<p>DRAG ME</p>
</div>
<div am-dnd>
<h3>DRAG OVER THIS AREA</h3>
<p>See the console, drag enter and leave are fired again and again while draging over
</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi quisquam, eaque, iure mollitia similique magnam voluptatem blanditiis distinctio nemo! Laboriosam porro iste maiores sequi magnam similique ad, in at. Omnis.</p>
</div>
</div>