@@ -26,6 +26,23 @@ export default function widgetBehavior(publicAPI, model) {
26
26
publicAPI . getHandle = ( handleIndex ) =>
27
27
model . widgetState [ handleGetters [ handleIndex ] ] ( ) ;
28
28
29
+ /**
30
+ * Return the index in the of tbe handle in `representations` array,
31
+ * or -1 if the handle is not present in the widget state.
32
+ */
33
+ publicAPI . getHandleIndex = ( handle ) => {
34
+ switch ( handle ) {
35
+ case model . widgetState . getHandle1 ( ) :
36
+ return 0 ;
37
+ case model . widgetState . getHandle2 ( ) :
38
+ return 1 ;
39
+ case model . widgetState . getMoveHandle ( ) :
40
+ return 2 ;
41
+ default :
42
+ return - 1 ;
43
+ }
44
+ } ;
45
+
29
46
publicAPI . isPlaced = ( ) =>
30
47
getNumberOfPlacedHandles ( model . widgetState ) === MAX_POINTS ;
31
48
@@ -159,12 +176,6 @@ export default function widgetBehavior(publicAPI, model) {
159
176
160
177
// Handles visibility ---------------------------------------------------------
161
178
162
- publicAPI . setMoveHandleVisibility = ( visibility ) => {
163
- model . representations [ 2 ] . setVisibilityFlagArray ( [ visibility , visibility ] ) ;
164
- model . widgetState . getMoveHandle ( ) . setVisible ( visibility ) ;
165
- model . representations [ 2 ] . updateActorVisibility ( ) ;
166
- } ;
167
-
168
179
/**
169
180
* Set actor visibility to true unless it is a NONE handle
170
181
* and uses state visibility variable for the displayActor visibility to
@@ -212,7 +223,7 @@ export default function widgetBehavior(publicAPI, model) {
212
223
}
213
224
if ( handleIndex === 1 ) {
214
225
publicAPI . placeText ( ) ;
215
- publicAPI . setMoveHandleVisibility ( false ) ;
226
+ publicAPI . loseFocus ( ) ;
216
227
}
217
228
} ;
218
229
@@ -278,6 +289,9 @@ export default function widgetBehavior(publicAPI, model) {
278
289
) {
279
290
if ( model . activeState . setOrigin ) {
280
291
model . activeState . setOrigin ( worldCoords ) ;
292
+ publicAPI . updateHandleVisibility (
293
+ publicAPI . getHandleIndex ( model . activeState )
294
+ ) ;
281
295
} else {
282
296
// Dragging line
283
297
publicAPI
@@ -355,7 +369,6 @@ export default function widgetBehavior(publicAPI, model) {
355
369
if ( ! model . hasFocus && ! publicAPI . isPlaced ( ) ) {
356
370
model . activeState = model . widgetState . getMoveHandle ( ) ;
357
371
model . activeState . setShape ( publicAPI . getHandle ( 0 ) . getShape ( ) ) ;
358
- publicAPI . setMoveHandleVisibility ( true ) ;
359
372
model . activeState . activate ( ) ;
360
373
model . _interactor . requestAnimation ( publicAPI ) ;
361
374
publicAPI . invokeStartInteractionEvent ( ) ;
@@ -372,6 +385,7 @@ export default function widgetBehavior(publicAPI, model) {
372
385
}
373
386
model . widgetState . deactivate ( ) ;
374
387
model . widgetState . getMoveHandle ( ) . deactivate ( ) ;
388
+ model . widgetState . getMoveHandle ( ) . setOrigin ( null ) ;
375
389
model . activeState = null ;
376
390
model . hasFocus = false ;
377
391
model . _widgetManager . enablePicking ( ) ;
0 commit comments