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 drag cursor on hover? #351

Open
4 tasks
lukasoppermann opened this issue Mar 6, 2018 · 10 comments
Open
4 tasks

Add drag cursor on hover? #351

lukasoppermann opened this issue Mar 6, 2018 · 10 comments
Labels
feature New feature or enhancement help wanted

Comments

@lukasoppermann
Copy link
Owner

lukasoppermann commented Mar 6, 2018

By default a cursor should indicate item that an item is draggable and change on drag.

This turns out to be very tricky. The states that need to be supported:

Must:

  • draggble: cursor: -moz-grab; cursor: -webkit-grab; cursor: grab;
  • dragged cursor: -moz-grabbing; cursor: -webkit-grabing; cursor: grabing;

Nice to have:

  • copy: when item is moved into list where it can be copied, show copy cursor
  • not-allowed: show not allowed cursor when moving somewhere on a sortable where the item can not be dropped.

Maybe this helps:

@CWSites
Copy link

CWSites commented May 3, 2018

I was able to accomplish this by adding the following to my CSS

.is-hovered {
    cursor: grab;
    cursor: -moz-grab;
    cursor: -webkit-grab;
}
.sortable-placeholder {
    cursor: grabbing !important;
    cursor: -moz-grabbing !important;
    cursor: -webkit-grabbing !important;
}

@lukasoppermann
Copy link
Owner Author

Can you upload an example of this? I remember having some issues when dragging.

@CWSites
Copy link

CWSites commented May 3, 2018

My config was as follows. I'll setup a codepen with a sample.

    sortable('.sortable', {
      forcePlaceholderSize: true,
      placeholderClass: 'sortable-placeholder',
      hoverClass: 'is-hovered'
    });

@CWSites
Copy link

CWSites commented May 3, 2018

Here is a codepen: https://codepen.io/CWSites/full/wjeNbb/

I noticed some odd behavior though, the sortable area is only the top row of objects even though I have adjusted the styles to be full width. The dark gray background is the sortable container but notice the red border only appears at the top. Similarly the grabbing cursor style only works in that top box and not 100% of the time.

@CWSites
Copy link

CWSites commented May 9, 2018

Hey @lukasoppermann I fixed all of the issues and improved the sortable-placeholder as well. Check out my referenced codepen above for a working example.

Configuration

sortable('.sortable', {
    forcePlaceholderSize: true,
    placeholderClass: 'sortable-placeholder',
    hoverClass: 'is-hovered'
});

Styles Applied

// Class of the element that is sortable
.box {
    cursor: grabbing;
    cursor: -moz-grabbing;
    cursor: -webkit-grabbing;
    &.is-hovered {
      cursor: grab;
      cursor: -moz-grab;
      cursor: -webkit-grab;
  }
}

// Class of the sortable place holder
.sortable-placeholder {
    cursor: grabbing;
    cursor: -moz-grabbing;
    cursor: -webkit-grabbing;
}

@CWSites
Copy link

CWSites commented May 10, 2018

Is this something that you would want added to the docs or code? Can you point me in the right direction of where I can contribute this update?

@lukasoppermann
Copy link
Owner Author

Hey, very neat, I think this issue should be enough as a reference. I would like this behaviour to be added as a default to the library, but of course that is a bit more complicated, as you can not rely on classes.

@joephuz
Copy link

joephuz commented Oct 22, 2019

this doesn't really work for me... i think this needs to be achieved by JS. The hover gets triggered when moving the element so its sets it back to 'grab'

@lukasoppermann
Copy link
Owner Author

Hey @joephuz would you be able to send a PR for this? That would be great.

@joephuz
Copy link

joephuz commented Oct 22, 2019

@lukasoppermann Ill give it a shot if i have some time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement help wanted
Projects
None yet
Development

No branches or pull requests

3 participants