Skip to content

DragControls not always hovering off objects #21375

@tb2k

Description

@tb2k

Describe the bug

When using DragControls the hoveroff event doesn't fire when the pointer moves from one draggable object to another without first moving off the original object. This doesn't impact the drag functionality but leaves objects without having hoveroff event code executed.

To Reproduce

  • With DragControls enabled hover directly from one draggable object to another.
  • See the live example below.

Code

The fix that works for me is to insert this code at line 107 of DragControls.js but I'm not experienced with javascript or three.js so I happily defer to the experts. I've prepared a branch with this fix as per the contribution instructions, please let me know if I should submit the pull request.

      if ( _hovered !== object && _hovered !== null) {

				scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );

				_domElement.style.cursor = 'auto';
				_hovered = null;
				
	}

Live example

  1. Go to https://did.makerchain.ca/dragcontrols.issue
  2. Click to add a few dividers and move the pointer over the divider intersections
  3. Notice that dividers get left coloured red.
  4. Go to https://did.makerchain.ca/dragcontrols.issue.fixed to see it working with my suggested DragControls.js change

Expected behavior

Objects should always have the hoveroff event fire.

Platform:

  • Device: Desktop
  • OS: MacOS
  • Browser: Chrome, Firefox
  • Three.js version: r126

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions