question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing cursor to grab/grabbing with dragHandle

See original GitHub issue

If anyone could provide an example with how I can use a grab and grabbing cursor with a drag handle, that would be great. Right now, no matter what CSS I try to use, the cursor seems to always go to default when dragging is active.

Edit: Closing this, I ended up using a workaround where I just applied a class to the whole document body

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

26reactions
zackifycommented, Aug 22, 2019

FYI heres’s how i did it:

onSortStart={() => (document.body.style.cursor = 'grabbing')}
onSortEnd={({ newIndex, oldIndex }: any) => {
    document.body.style.cursor = 'default';
...

then on your drag handler make sure to put cursor: grab on it

4reactions
arosisicommented, Jul 12, 2020

FYI heres’s how i did it:

onSortStart={() => (document.body.style.cursor = 'grabbing')}
onSortEnd={({ newIndex, oldIndex }: any) => {
    document.body.style.cursor = 'default';
...

then on your drag handler make sure to put cursor: grab on it

Just to add to @zackify 's approach, to make sure that the cursor will not change when you drag over, say a button (it may change to a pointer), you can do this:

onSortStart={() => (document.body.className = 'grabbing')}
onSortEnd={({ newIndex, oldIndex }: any) => {
  document.body.className = '';
...

where grabbing is

grabbing {
  cursor: grabbing;
}
grabbing * {
  cursor: grabbing;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS for grabbing cursors (drag & drop)
So I want the cursor to change when they're hovering over the background. The -moz-grab and -moz-grabbing CSS cursors are ideal for this....
Read more >
Change cursor when grabbing an item - GSAP
You can use the Draggable property cursor, to set the initial CSS cursor property to grab for when hovered. And then onDragStart set...
Read more >
Changing cursor to grab/grabbing with dragHandle - JavaScript ...
3 Answer: FYI heres's how i did it: onSortStart={() => (document.body.style.cursor = 'grabbing')} onSortEnd={({ ...
Read more >
The cursor: default, pointer, grab, grabbing - Phaser 3
One makes objects interactive with setInteractive(). Apparently this code can only be executed once on an object? Afterwards have to set this.
Read more >
Grab & Drag
cursor : -moz-grabbing;. 17. cursor: -o-grabbing;. 18. cursor: -ms-grabbing;. 19. cursor: grabbing;. 20. } 21. ​. 22. $purple: #d94fed !default;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found