Skip to content

Commit 4e204db

Browse files
authored
DragControls: Ensure hoveroff is fired correctly. (mrdoob#21376)
* added a condition to catch the case where a hovered object doesn't get hoveredoff before a different object is hoveredon. * DragControls fix for issue mrdoob#21375
1 parent f4a6658 commit 4e204db

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

examples/js/controls/DragControls.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
105105

106106
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) );
107107

108+
if ( _hovered !== object && _hovered !== null) {
109+
110+
scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
111+
112+
_domElement.style.cursor = 'auto';
113+
_hovered = null;
114+
115+
}
116+
108117
if ( _hovered !== object ) {
109118

110119
scope.dispatchEvent( { type: 'hoveron', object: object } );

examples/jsm/controls/DragControls.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ var DragControls = function ( _objects, _camera, _domElement ) {
114114

115115
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) );
116116

117+
if ( _hovered !== object && _hovered !== null) {
118+
119+
scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
120+
121+
_domElement.style.cursor = 'auto';
122+
_hovered = null;
123+
124+
}
125+
117126
if ( _hovered !== object ) {
118127

119128
scope.dispatchEvent( { type: 'hoveron', object: object } );

0 commit comments

Comments
 (0)