Skip to content

Commit

Permalink
feat: remove unused bind
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Dec 2, 2024
1 parent 1071310 commit 81fe684
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/primitives/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,20 @@ function smoothDrawing(c: SelfEventContenxt) {
const progress = Math.min(elapsed / animationDuration, 1)
if (self.forceDestroy || progress >= 1) {
effect.stop()
self.highlight.reset()
self.highlight.setDisplayLayerForHighlight()
return true
}
const easedProgress = easing.cubicInOut(progress)
self.highlight.reset()
const mask = createFillBlock(x, y, w, h, { fill, opacity: 0.4, radius: 2, margin: 2 })
self.highlight.highlight.add(mask)
self.highlight.setDisplayLayerForHighlight('1')
self.highlight.setZIndexForHighlight('1')
applyForOpacity(mask, 0.4, 0.4, easedProgress)
stackMatrixTransform(mask, self.translateX, self.translateY, self.scaleRatio)
self.highlight.highlight.update()
})
} else {
self.highlight.reset()
self.highlight.setDisplayLayerForHighlight()
self.highlight.setZIndexForHighlight()
}
}

Expand Down Expand Up @@ -205,7 +203,7 @@ export class SelfEvent extends RegisterModule {
}
// If highlighting is triggered, it needs to be destroyed first
this.self.highlight.reset()
this.self.highlight.setDisplayLayerForHighlight()
this.self.highlight.setZIndexForHighlight()
// @ts-expect-error
this.self.event.off('mousemove', this.self.onmousemove)
this.treemap.event.off(internalEventMappings.ON_ZOOM)
Expand Down Expand Up @@ -234,6 +232,7 @@ export class SelfEvent extends RegisterModule {
this.self.translateY += drawY
this.self.draggingState = { x, y }
stackMatrixTransformWithGraphAndLayer(this.treemap.elements, this.self.translateX, this.self.translateY, this.self.scaleRatio)

this.treemap.update()
})
}
Expand All @@ -244,7 +243,7 @@ export class SelfEvent extends RegisterModule {
}
this.self.isDragging = false
this.self.highlight.reset()
this.self.highlight.setDisplayLayerForHighlight()
this.self.highlight.setZIndexForHighlight()
this.self.event.bindWithContext(this)('mousemove', this.self.onmousemove)
}

Expand Down Expand Up @@ -280,7 +279,7 @@ export class SelfEvent extends RegisterModule {
self.forceDestroy = true

this.self.highlight.reset()
this.self.highlight.setDisplayLayerForHighlight()
this.self.highlight.setZIndexForHighlight()
const factor = absWheelDelta > 3 ? 1.4 : absWheelDelta > 1 ? 1.2 : 1.1
const delta = wheelDelta > 0 ? factor : 1 / factor
const targetScaleRatio = self.scaleRatio * delta
Expand Down Expand Up @@ -371,13 +370,11 @@ export class SelfEvent extends RegisterModule {
this.highlight.init(width, height, root)

if (!installHightlightEvent) {
bindPrimitiveEvent(this.highlight.highlight.render.canvas, { treemap, self: this }, 'mousemove', event)
bindPrimitiveEvent(this.highlight.highlight.render.canvas, { treemap, self: this }, 'mouseout', event)
// highlight
selfEvt('mousemove', this.onmousemove)
selfEvt('mouseout', this.onmouseout)
installHightlightEvent = true
this.highlight.setDisplayLayerForHighlight()
this.highlight.setZIndexForHighlight()
}
this.highlight.reset()
})
Expand Down Expand Up @@ -504,14 +501,14 @@ function isScrollWheelOrRightButtonOnMouseupAndDown<E extends DuckE = DuckE>(e:
interface HighlightContext {
init: (w: number, h: number, root: HTMLElement) => void
reset: () => void
setDisplayLayerForHighlight: (layer?: string) => void
setZIndexForHighlight: (layer?: string) => void
get highlight(): Schedule
}

function createHighlight(): HighlightContext {
let s: Schedule | null = null

const setDisplayLayerForHighlight = (layer: string = '-1') => {
const setZIndexForHighlight = (layer: string = '-1') => {
if (!s) return
const c = s.render.canvas
c.style.zIndex = layer
Expand All @@ -521,7 +518,7 @@ function createHighlight(): HighlightContext {
if (!s) {
s = new Schedule(root, { width: w, height: h })
}
setDisplayLayerForHighlight()
setZIndexForHighlight()
s.render.canvas.style.position = 'absolute'
s.render.canvas.style.pointerEvents = 'none'
}
Expand All @@ -535,7 +532,7 @@ function createHighlight(): HighlightContext {
return {
init,
reset,
setDisplayLayerForHighlight,
setZIndexForHighlight,
get highlight() {
return s!
}
Expand Down

0 comments on commit 81fe684

Please sign in to comment.