Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvFileOver's class doesn't get removed when file is moved out from the element #231

Closed
mr-moon opened this issue Sep 3, 2014 · 23 comments
Closed

Comments

@mr-moon
Copy link

mr-moon commented Sep 3, 2014

Just as subj. I'm on OS X 10.9 Chrome 37.0.2062.94,

@mr-moon
Copy link
Author

mr-moon commented Sep 3, 2014

Just a little screen capture: http://cl.ly/3G1T3l211O1l

@drsouly
Copy link

drsouly commented Sep 5, 2014

same here ..

@EccoTheDolphin
Copy link
Contributor

Same here for chromium 39.0.2138.3 and Mozilla Firefox 24.7.0

Steps to reproduce:

javascript:

angular
    .module('app', ['angularFileUpload'])
        .controller('AppController', function($scope, FileUploader) {
                  $scope.uploader = new FileUploader();
                      });

css:

.nv-file-over { border: none !important; }

.buggy-drop-zone {
    width : 400px;
    height : 400px;
    border : 0;
}

.buggy-drop-zone * {
    border-color : black;
    border : solid;
    width  : 100%;
    height : 100%;
}

.buggy-drop-zone.nv-file-over * {
    background : red;
}

html (interesting part):

<div ng-app="app">
        <div ng-controller="AppController"
            class="buggy-drop-zone"
            nv-file-over
            nv-file-drop=""
            uploader="uploader"
            >
            <div>
            </div>
        </div>
    </div>

When we drag file into the buggy-drop-zone area - background of the inner div switches to red. But when we move it out - it stays the same (instead of switching back to default).

For workaround you can use something like that:

.buggy-drop-zone * {  pointer-events : none; }

@EccoTheDolphin
Copy link
Contributor

I think that current behavior is incorrect. For example:

.drop-zone {
    height : 200px;
    width : 300px;
    border : solid 1px black;
}
.nasty-item {
    text-align: center;
    background : lightgray;
    position : relative;
    top : 45%;
}
<div ng-controller="AppController" class="drop-zone"  nv-file-over  nv-file-drop="" uploader="uploader">
    <div class="nasty-item"><span>
        Drag file along this element
        <br>
        (accelerate near the left/right boder)
      </span></div>
</div>

then, if user moves file out of drop-zone along the <div><span></span></div>, and if he does it quite fast (or root element has no border) - in that case onDragLeave will not be triggered.

nervgh added a commit that referenced this issue Sep 22, 2014
Maybe we should allow child element to trigger onDragLeave (#231) ?
@nervgh
Copy link
Owner

nervgh commented Sep 25, 2014

fixed #237

@nervgh nervgh closed this as completed Sep 25, 2014
@shinrox
Copy link

shinrox commented Aug 31, 2015

This issue is still happening, go to example pages then drag a file over/out the window.

Tested on Mac OSX 10.10.5
Chrome 44.0.2403.157
Firefox 40.0.3

@chaim-alter
Copy link

I have the same issue, and this is my workaround.

element.on('dragleave', function () {
    $(this).removeClass('file-over-now-class');
});

@kuafucode
Copy link

+1 even exists in example link

@celsomtrindade
Copy link

+1 same here. On my page and on example link. tested on chrome and firefox. Both with same issue.

The class only get removed if the file is added to queue. But if i hover the file on the drop zone and leave without adding the file, the class will stay applied.

@pyrostrex
Copy link

Just to add to @chaim-kedem's workaround, if you have child inside the element, you should add pointer-events: none; to the css of your child element to prevent flickers. Credits to http://stackoverflow.com/a/14027995

@v-zabavsky
Copy link

A simple decorator to the nvFileOver directive:

(function () {
    'use strict';
    appModule.config(function ($provide) {
        $provide.decorator('nvFileOverDirective', function ($delegate) {
            var directive = $delegate[0],
                link = directive.link;

            directive.compile = function () {
                return function (scope, element, attrs) {
                    var overClass = attrs.overClass || 'nv-file-over';
                    link.apply(this, arguments);
                    element.on('dragleave', function () {
                        element.removeClass(overClass);
                    });
                };
            };

            return $delegate;
        });
    });
})();

Thanks @chaim-kedem for the workaround and @thijsw for the hint.
I hope that helps.

@thijsw
Copy link

thijsw commented Nov 13, 2015

In addition to the fix proposed by @chaim-kedem: the fix shouldn't depend on jQuery because you could just use element its removeClass() method

element.on('dragleave', function () {
    element.removeClass('file-over-now-class');
});

@luncht1me
Copy link

Nothing here has really worked flawlessly for me yet..... Can we get a patch that handles drag leave ??

@liadlivnat
Copy link

Hello ?? can anyone commit a fix for that ?

@gimoteco
Copy link

The problem still happening in version 2.2.0, you can check in the sample pages. When you get out from drop zone the over-class remains.

@nestdimon
Copy link

+1

2 similar comments
@miliare
Copy link

miliare commented May 18, 2016

+1

@rknell
Copy link

rknell commented Jun 2, 2016

+1

@blackmiaool
Copy link

blackmiaool commented Aug 3, 2016

$(document.body).mouseenter(function(){
    $(this).removeClass("[nvFileOver's class]");
})

This makes the target page not that bad at least.

@PeterClough
Copy link

Seems to be this line on line no. 1706 of angular-file-upload.js I wonder why it's there...

if (event.currentTarget === this.element[0]) return;

@jameseddyedwards
Copy link

This line appears to be added for a flickering issue for Chrome which I'd imagine could have been solved with CSS alone. I think it needs to take into account whether the nv-file-over directive is applied to the same element as the nv-file-drop so actually changing this to a !== seems to make more sense and is the fix I've applied.

@mohitsudhakar
Copy link

Does this issue still exist?

@MGZero
Copy link

MGZero commented Mar 5, 2020

Still not working in 2.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests