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

add class on dragover #460

Closed
fxck opened this issue Jun 28, 2015 · 9 comments
Closed

add class on dragover #460

fxck opened this issue Jun 28, 2015 · 9 comments

Comments

@fxck
Copy link

fxck commented Jun 28, 2015

..if that's the right event, I'd like to add a class to the list an item is being added to

something like

.sortable-there-a-thing-hovering-over-me

@philipzaengle
Copy link

+1 This would be really handy!

@seank-com
Copy link
Contributor

You can do this using the onMove event handler.

Sortable.create(el, {
  group: {
    name: 'stocking',
    put: false,
    pull: 'clone'
  },
  onMove: function (evt) {
    // et.to will always be the list you are over but evt.related 
    // will be === only the very first time evt.to changes
    if (evt.related === evt.to) {
      Sortable.utils.toggleClass(evt.to, 'highlight', true);
    }
  }
});

only problem is that there is nothing currently tracking the item you hovered over before hovering over this item, since the evt.from is the original list you are dragging from. I'm working on adding an evt.previous to do just this, but the dev branch has at least one issue that is slowing me down some. Note: The onMove handler is called on the sortable list the item is dragged from not the list/lists being hovered or dropped on.

@emmettnicholas
Copy link

+1 This would be analogous to jQuery-UI-sortable's "over" and "out" events: http://api.jqueryui.com/sortable/#event-over

@dzineduk
Copy link

dzineduk commented Jul 1, 2016

+1 from me, this would be awesome, I'm dragging from one list to a sortable one and would like to be able to remove some classes from the dragged element when its hovering in the drop area!

Plugin is awesome by the way!

@valentinvoilean
Copy link

I created a pull request for this: #991
Maybe it's not the best code, but at least it works ;) .

@philippkuehn
Copy link

+1
is there any news on this?

@owen-m1
Copy link
Member

owen-m1 commented Apr 8, 2019

Here is solution: #1468

@waynevanson
Copy link
Contributor

Closing because this has been answered.

@lk77
Copy link

lk77 commented May 20, 2021

Hello,

in my case i'm using vue draggable, so i can do :

<draggable @dragover.native="console.log('dragover')"/>

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

10 participants