Skip to content

Commit

Permalink
Disable browser fixes when mixin is inactive
Browse files Browse the repository at this point in the history
This prevents false positives when `dragover` and `drop` aren't caused by mixin, for example when dragging files over the browser window.
  • Loading branch information
gaearon committed Oct 23, 2014
1 parent 8060c8a commit 48b2ba8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/mixins/DragDropMixin.js
Expand Up @@ -186,7 +186,7 @@ function resetGlobalDragState() {

if (isWebkit()) {
window.addEventListener('dragover', function (e) {
if (checkIfCurrentDragTargetRectChanged()) {
if (_currentDragTarget && checkIfCurrentDragTargetRectChanged()) {
// Prevent animating to incorrect position
e.preventDefault();
}
Expand All @@ -198,8 +198,8 @@ if (isWebkit()) {
* We will attempt to fire it ourselves when global `drop` occurs.
*/
function triggerDragEndIfDragSourceWasRemovedFromDOM() {
if (_handleCurrentDragEnd &&
_currentDragTarget &&
if (_currentDragTarget &&
_handleCurrentDragEnd &&
!document.contains(_currentDragTarget)) {

_handleCurrentDragEnd();
Expand All @@ -218,6 +218,10 @@ if (!isFirefox()) {
var _lastDragSourceCheckTimeout = null;

window.addEventListener('dragover', function () {
if (!_currentDragTarget) {
return;
}

clearTimeout(_lastDragSourceCheckTimeout);

_lastDragSourceCheckTimeout = setTimeout(
Expand Down Expand Up @@ -479,4 +483,4 @@ var DragDropMixin = {
}
};

module.exports = DragDropMixin;
module.exports = DragDropMixin;

0 comments on commit 48b2ba8

Please sign in to comment.