@@ -173,7 +173,7 @@ function bindPrimitiveEvent(
173
173
native : e ,
174
174
module : findRelativeNode ( { x, y } , treemap . layoutNodes )
175
175
}
176
- // @ts -expect-error
176
+ // @ts -expect-error safe
177
177
bus . emit ( evt , event )
178
178
}
179
179
c . addEventListener ( evt , handler )
@@ -234,8 +234,7 @@ export class SelfEvent extends RegisterModule {
234
234
// If highlighting is triggered, it needs to be destroyed first
235
235
this . self . highlight . reset ( )
236
236
this . self . highlight . setDisplayLayerForHighlight ( )
237
- // @ts -expect-error
238
- this . self . event . off ( 'mousemove' , this . self . onmousemove )
237
+ this . self . event . off ( 'mousemove' , this . self . onmousemove . bind ( this ) )
239
238
this . treemap . event . off ( internalEventMappings . ON_ZOOM )
240
239
this . self . forceDestroy = true
241
240
const { native } = metadata
@@ -263,7 +262,7 @@ export class SelfEvent extends RegisterModule {
263
262
this . self . draggingState = { x : 0 , y : 0 }
264
263
this . self . highlight . reset ( )
265
264
this . self . highlight . setDisplayLayerForHighlight ( )
266
- this . self . event . bindWithContext ( this ) ( 'mousemove' , this . self . onmousemove )
265
+ this . self . event . bindWithContext ( this ) ( 'mousemove' , this . self . onmousemove . bind ( this ) )
267
266
}
268
267
269
268
onmousemove ( this : SelfEventContenxt , metadata : PrimitiveEventMetadata < 'mousemove' > ) {
@@ -285,8 +284,9 @@ export class SelfEvent extends RegisterModule {
285
284
286
285
onwheel ( this : SelfEventContenxt , metadata : PrimitiveEventMetadata < 'wheel' > ) {
287
286
const { self, treemap } = this
288
- // @ts -expect-error
289
- const wheelDelta = metadata . native . wheelDelta
287
+
288
+ // @ts -expect-error safe
289
+ const wheelDelta = metadata . native . wheelDelta as number
290
290
const absWheelDelta = Math . abs ( wheelDelta )
291
291
const offsetX = metadata . native . offsetX
292
292
const offsetY = metadata . native . offsetY
@@ -332,17 +332,18 @@ export class SelfEvent extends RegisterModule {
332
332
}
333
333
]
334
334
mixin ( app , methods )
335
+ const selfCtx = { treemap, self : this }
335
336
const selfEvents = [ ...primitiveEvents , 'wheel' ] as const
336
337
selfEvents . forEach ( ( evt ) => {
337
- nativeEvents . push ( bindPrimitiveEvent ( treemap . render . canvas , { treemap , self : this } , evt , event ) )
338
+ nativeEvents . push ( bindPrimitiveEvent ( treemap . render . canvas , selfCtx , evt , event ) )
338
339
} )
339
- const selfEvt = event . bindWithContext < SelfEventContenxt > ( { treemap , self : this } )
340
- selfEvt ( 'mousedown' , this . ondragstart )
341
- selfEvt ( 'mousemove' , this . ondragmove )
342
- selfEvt ( 'mouseup' , this . ondragend )
340
+ const selfEvt = event . bindWithContext < SelfEventContenxt > ( selfCtx )
341
+ selfEvt ( 'mousedown' , this . ondragstart . bind ( selfCtx ) )
342
+ selfEvt ( 'mousemove' , this . ondragmove . bind ( selfCtx ) )
343
+ selfEvt ( 'mouseup' , this . ondragend . bind ( selfCtx ) )
343
344
344
345
// wheel
345
- selfEvt ( 'wheel' , this . onwheel )
346
+ selfEvt ( 'wheel' , this . onwheel . bind ( selfCtx ) )
346
347
347
348
applyZoomEvent ( { treemap, self : this } )
348
349
@@ -352,11 +353,9 @@ export class SelfEvent extends RegisterModule {
352
353
this . highlight . init ( width , height , root )
353
354
354
355
if ( ! installHightlightEvent ) {
355
- bindPrimitiveEvent ( this . highlight . highlight . render . canvas , { treemap, self : this } , 'mousemove' , event )
356
- bindPrimitiveEvent ( this . highlight . highlight . render . canvas , { treemap, self : this } , 'mouseout' , event )
357
356
// highlight
358
- selfEvt ( 'mousemove' , this . onmousemove )
359
- selfEvt ( 'mouseout' , this . onmouseout )
357
+ selfEvt ( 'mousemove' , this . onmousemove . bind ( selfCtx ) )
358
+ selfEvt ( 'mouseout' , this . onmouseout . bind ( selfCtx ) )
360
359
installHightlightEvent = true
361
360
this . highlight . setDisplayLayerForHighlight ( )
362
361
}
@@ -394,6 +393,7 @@ function estimateZoomingArea(node: LayoutModule, root: LayoutModule | null, w: n
394
393
let siblingWeightSum = 0
395
394
396
395
for ( const sibling of siblings ) {
396
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
397
397
siblingWeightSum += sibling . weight
398
398
}
399
399
0 commit comments