GithubHelp home page GithubHelp logo

bevacqua / dragula Goto Github PK

View Code? Open in Web Editor NEW
21.8K 359.0 2.0K 1.91 MB

:ok_hand: Drag and drop so simple it hurts

Home Page: https://bevacqua.github.io/dragula/

License: MIT License

CSS 4.98% JavaScript 78.41% HTML 16.30% Stylus 0.30%
javascript front-end drag-and-drop vanilla drag-drop dragging component

dragula's People

Contributors

adamkdean avatar beatfreaker avatar benib avatar bevacqua avatar charbelrami avatar connorkrammer avatar daleeidd avatar dcantatore avatar debone avatar djhopper01 avatar dougludlow avatar elrumordelaluz avatar foxolot avatar frantz avatar gnujeremie avatar heroiceric avatar jimf avatar luckylooke avatar maralmosayebi avatar marg51 avatar mattpk avatar maxxwyndham avatar mfsousa avatar nathanwalker avatar nickdecorte avatar peterjosling avatar phillipalexander avatar prayagverma avatar sethmcleod avatar tschuy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dragula's Issues

allow addContainer to take container id

in my use case, i'll be adding containers dynamically to the page, making them part of dragula containers. therefore those will have dynamically created ids.
it would be ideal to be able to pass the id to the drake.addContainer method (addContainer("left2")
I've also tried passing the dom object through jquery, such as addContainer($("#left2")), but i'm getting an error when doing so.
only addContainer(left2) seems to work

Adding/removing containers

I was wondering, is it possible to remove and add the containers dynamically currently?
Because it happens in our use cases a lot that we drop or add a container depending on the situation at hand.

If not: as I was looking at the code. I think it can be either done by having an update function in the api that checks if the containers variable which was passed has changed and adds and removes the elements accordingly. Or just have an add and remove function added to the api.

Direction and item sizes

Hi, this is a super bit of code.

Is it possible to have items of different sizes which can flow left to right across the page? Something like jumbled up words that can be re-arranged in their proper order?

Phil Bolt

Container can't be dragged

Sorry for bothering you again.
I edited your first demo example so that the right container is inside the left one. The drag and drop function works perfectly but the container won't be dragged. The container moves up if I'm dropping items below it but it won't come down again since I can't drag it. Do I have to edit something or maybe this will be in the future release?
I don't have any advance experience in Javascript so I don't really know how your code works.
Thanks for the answer.

Please provide examples of the use of drake events

Could you add examples on how to use the drake events, i'm thinking for instance at running a function at every time an element is dropped, but couldn't figure out how to do it properly.
This would really help.
Thx in advance

not usable on IE mobile

I have troubles to use your demo on a Windows Phone. It seems default behaviour (e.g. scrolling) of touch events isn't blocked correctly. That makes it unusable.

Necessity & Bug[removeOnSpill] (?)

dragcopy

I need the user drag options from white zone to the black (down), I added on the drop event the necessary thing to prevent the user drop from black to white because is not allowed but when i move from right to left in black zone it copies and i need to stop the copy.

I have the following code :

        $(function(){
            dragula([left1, right1,top1],{
                removeOnSpill: true,
                copy:true,
            }).on('drop', function (el, target, source) {

                if(source == left1 && target == top1){
                    alertify.error("Sie können keine Optionen hinzufügen");
                    el.remove();
                    return false;
                }

                if(source == right1 && target == top1){
                    alertify.error("Sie können keine Optionen hinzufügen");
                    el.remove();
                    return false;
                }

                if(source == left1 && target == right1){
                    // I need to remove the origin element from here
                    // removeOriginElement();
                }
            });
        });    

I would really appreciate your help with this, do i need to handle accepts method ?, how ?
And finally , i have the removeOnSpill set to true, and is not working.

Excelent library 👍 and very useful, thanks.

Item missplaced on drag

Something I noticed when trying out the samples on Firefox 39.0a2: http://imgur.com/8YPS2OP
When you drag the second example, the dragged items stay near the previous example. On the screen cap you can't see the mouse cursor, but it is down on the second box.

Tested on IE 11.0.96 and happens the same.

IE8 compability Array.isArray

dragula.js line 47, character 7

You use isArray function, but this function supports from IE9.. Array.isArray()

So without polyfills your library don't work in IE less than 9.. And in Readme no info about this issue

How can I set dynamic containers?

I have two Backbone views that are rendering in different placeholders at different time and I want to drag element from one view and drop it into another. Is it possible to do?

"If you move me I'll just come back here..."

It let's me move it so I'm confused. It makes it sound like it should remain in its place in the element, even if I try to drag it to another box.

Poorly worded or not functioning?

Chrome 41 in case that matters.

Container ids with dashes gives an error

Anytime I try to specify a container id with a dash in it (i.e. left-container) for the initial dragula call I get an error. So:

dragula([leftcontainer,rightcontainer]) will work but
dragula([left-container,right-container]) won't

Specifying containers currently seems to take advantage of the automatically defined properties on the Window object - it would be helpful if we could also specify any id so long as it's valid according to the spec.

Why use '.js' on bower package?

Very nice lib, but, I'm trying to use it in a rails project, and I'm getting some problems:

  1. I couldn't get how to install it manually, it depends from some libs and this is not very well documented;
  2. I couldn't use rails-assets for it, because the name of it on bower have the dot char, which is an invalid name for a ruby gem. This could be handled on rails-assets gem generator of course, but I don't really know which are the best practices for naming for bower packages.

So, if you could just explain which libs you depend from, to some other people that want to install it manually, it would be very helpful. The second point is optional, but IMHO it would be better a name without dot (PS: why not just 'dragula', since this package name is not in use on bower yet)

How to get click events?

Hi, thanks for the great lib. I'm creating dynamically a div container with div's inside that I want to drag, but I also want to be able to click on each div to trigger some code. However when I use dragula on my container, it hides the click event, unless I do a CMD + click (on mac). I want to get the click event without user having to press additional keys... Any suggestion? Thank you.

Containers?

This might be a stupid question, but I'm looking at your example code and I can't figure out where you defined the containers (left, right, single, etc)?

crossvent.js?

Ok, I am loading in the head, but what is crossvent.js?

I can't even find it on my system, but dragula is dying there in "function addEventEasy"

Color me confused...

Can't use font-awesome i tag as handle

I've just discovered this library today, and i really like it.
A couple of issues i'm encountering though, first with the use of a font-awesome styled , either within a span or not, this won't take it as the handle.
it will work ok with an empty span for instance, but as soon as i set the tag inside the span, it stops working.
same thing with the tag also holding the handle class

lot improvements

i gonna add pr with gulpfile with the following tasks:

  1. Minification
  2. Adding banner (info in top of dist files about plugin, author and repo)
  3. Much module systems in dist? (es6, amd, jquery plugin). i offer to rewrite general library to globals format and then to build for different module systems.

may I send such a pr?

Using class instead of Id?

One night, I'm searching for the latest jquery drag and drop feature and got this from google search. Reading down the readme and then the scare jump appears! Then I decided to check it on day only.

After some testing I realize that it's needed to be an id to be a container. Can we just use class for it so then the container will be more dynamic (I mean add new container or even container inside container)? Or are there workaround for this?

No mirror element while dragging

When i start dragging an element they are no mirror element that follow the mouse.

My element is just a simple img in a span :

On iOS 8, removeOnSpill is always triggered

When I re-order any element of the 3rd demo ( removeOnSpill ), on Safari 8 and Chrome, the element is removed.
It's correctly re-ordered on desktop Chrome.

dragula

( iPhone 6, iOS 8.1.2 ).

The project is impressive tho ; )

Dropping item in one container but not another

Awesome tool! It's way more intuitive/light than anything else I've tried.

I'm running into a problem, though, that I can't figure out, and seems to be throwing a warning.

I have two containers. I want to be able to copy items from the right to the left, and move them around the left, but not copy from the left to the right.

I tried the following (in Angular, so s is a essentially global object):

var stopDrop;

s.drakeLeftRight = dragula([left, right], {
  revertOnSpill: true,
  copy: true
});

s.drakeLeft = dragula([left], {
  removeOnSpill: true
});

stopDrop = function(container) {
  if (!_.contains(container.classList, 'left')) {
    return s.drakeLeftRight.cancel();
  }
};

s.drakeLeftRight.on('drop', function(el, container, source) {
  return setTimeout((function() {
    return stopDrop(container);
  }), 0);
});

The hope was that the s.drakeLeftRight.cancel() would "cancel" the drop of the item from the left list if it wasn't dropped into the right.

It also throws this in the console:

Uncaught TypeError: Cannot read property 'className' of null

But the actual behavior is currently that the item transfers (not copies) from the left to the right, disappearing from the left. I've also tried giving cancel an argument of the container into which it's being dropped (thinking, partially because of the above error, that the revert argument might refer to the container from which the item should be cancelled).

No dice. Similarly no dice if I use remove(), which takes the item out from both sides.

Any idea how to do this?

Firefox: Incorrect element position while dragging

When I try to drag an element after I have scrolled down any amount, the copy element being dragged is incorrectly positioned.
Screenshots attached
Latest version of FireFox
Tested on Chrome with no issue

Before scrolling
dragula_ff_1

After scrolling
dragula_ff_2

Shadow position when revertOnSpill == true

I was playing around with the demo and noticed that setting revertOnSpill to true results in a misleading shadow position. By this I mean that if you move the item down the list so that its shadow goes from, say, the first to the third position, moving the item out of the box leaves the shadow in the third position. This would seem to indicate to a user that letting go would snap it to the third position, when it would really return to the first.

Steps to reproduce, for clarity:

  1. Grab item
  2. Drag so that shadow indicates new position
  3. Move item outside of drop-friendly zone
  4. Note how shadow does not revert to original position

The main issue with this is that a user can't tell the difference between a box where revertOnSpill == true and one where revertOnSpill == false without making a mistake with their drag. There's a chance that it actually moves to the indicated area, but there's also a chance that it returns to the original position -- that's a confusing and potentially harmful experience. Consider the case where a user drags a document over a trash icon, then changes their mind. They attempt to cancel the drag by moving the mouse outside the drop zone, but the item is deleted anyway -- they assumed revertOnSpill was true, when it was actually false.

Different styling while dragging.

Hi there!

Thank you so much for Dragula! It's pretty awesome and works as promised out of the box. I just have one little issue. While dragging the width of the object isn't kept the same. Before dragging it looks like this:
schermafbeelding 2015-05-12 om 16 34 00
While dragging it looks like this:
schermafbeelding 2015-05-12 om 16 34 40
And after dropping it looks just as it should be.

Do you have any idea what the problem could be? If you need a codepen I can probably fix that! ;)
Thanks in advance!

Drop not working

The drag work but there is no drop and no interaction with containers.

This is cause by setting .gu-mirror position absolute but if i don't set position absolute the mirror is not following my cursor and is just stick in the bottom left corner.

Codepen : http://codepen.io/anon/pen/yNBVqa

Query

Is it possible to drag all the child elements inside a div ?

drag and drop

I followed the pattern he showed in the gif but it didn't work in google chrome

Turning it on/off

I need to be able to go into drag mode, and then turn it off.

Is there a way to do that?

The only way I think it could be done is to keep a Drake object around and add/remove containers, is that the way?

Can't load dragula in <head>

It seems when loading dragula in <head>, the local body variable is null, which causes all kinds of problems. It seems this is due to document.body being null at the time body is defined: https://github.com/bevacqua/dragula/blob/master/dragula.js#L5

To state the obvious -- I know the ideal solution here is "don't put your scripts in <head>", but unfortunately I have a very large codebase that does exactly the opposite 😑... Maybe dragula could support this? I'd be happy to attempt a PR if you're amenable to it.

Here's a demo showing the problem: http://ryanfunduk.com/dragula-test.html
Same page but loading at EOB: http://ryanfunduk.com/dragula-works.html

Thanks for dragula, btw! It's looking like the drag&drop lib of my dreams :)

custom domain for gh page

I have seen you have set up a GitHub Page. If you are interested in the custom domain dragula.js.org for free you should have a look at JS.ORG. I would appreciate your request.

Drag Handles

It would be great if one could specify a css selector for drag handles.

Target element by class

Is it possible to pass class instead of id to target an element ? Something like:

Move me, but you can only drop me in one of these containers.
If you try to drop me somewhere other than these containers, I'll just come back.
You can drop me in the left container, otherwise I'll stay here.

dragula([.left1, .right1]); ??

One more thing, how can i know where dragged element is dropped? Can i see exact tag that element was dropped IN?

Thanks in advance.

Invariant Violation when using React.js

When using dragula to drag and drop react element's an error is throw because cloning elements will end up having two elements with same data-reactid attribute.

This is what the log says:

Uncaught Error: Invariant Violation: ReactMount: Two valid but unequal nodes with the same `data-reactid`: .0.0.0.1:$0.0.4.1.0.0.3.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.