File tree 1 file changed +20
-16
lines changed
1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -189,30 +189,34 @@ class CadControl extends Control {
189
189
` ;
190
190
}
191
191
192
+ handleInteractionAdd = ( e ) => {
193
+ const pos = e . target . getArray ( ) . indexOf ( this . snapInteraction ) ;
194
+
195
+ if (
196
+ this . snapInteraction . getActive ( ) &&
197
+ pos > - 1 &&
198
+ pos !== e . target . getLength ( ) - 1
199
+ ) {
200
+ this . deactivate ( true ) ;
201
+ this . activate ( true ) ;
202
+ }
203
+ } ;
204
+
192
205
/**
193
206
* @inheritdoc
194
207
*/
195
208
setMap ( map ) {
209
+ if ( this . map ) {
210
+ this . map . getInteractions ( ) . un ( 'add' , this . handleInteractionAdd ) ;
211
+ }
212
+
196
213
super . setMap ( map ) ;
197
214
198
215
// Ensure that the snap interaction is at the last position
199
216
// as it must be the first to handle the pointermove event.
200
- this . map . getInteractions ( ) . on (
201
- 'add' ,
202
- ( ( e ) => {
203
- const pos = e . target . getArray ( ) . indexOf ( this . snapInteraction ) ;
204
-
205
- if (
206
- this . snapInteraction . getActive ( ) &&
207
- pos > - 1 &&
208
- pos !== e . target . getLength ( ) - 1
209
- ) {
210
- this . deactivate ( true ) ;
211
- this . activate ( true ) ;
212
- }
213
- // eslint-disable-next-line no-extra-bind
214
- } ) . bind ( this ) ,
215
- ) ;
217
+ if ( this . map ) {
218
+ this . map . getInteractions ( ) . on ( 'add' , this . handleInteractionAdd ) ;
219
+ }
216
220
}
217
221
218
222
/**
You can’t perform that action at this time.
0 commit comments