Skip to content

Commit

Permalink
fix: fix overlay zLevel error. #489
Browse files Browse the repository at this point in the history
  • Loading branch information
liihuu committed Nov 20, 2023
1 parent fa7b9cf commit ac27009
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
22 changes: 2 additions & 20 deletions src/component/Overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ export interface Overlay {
*/
visible: boolean

/**
* Default draw level
*/
defaultZLevel: number

/**
* Draw level
*/
Expand Down Expand Up @@ -278,8 +273,8 @@ export interface Overlay {
onDeselected: Nullable<OverlayEventCallback>
}

export type OverlayTemplate = ExcludePickPartial<Omit<Overlay, 'id' | 'groupId' | 'paneId' | 'defaultZLevel' | 'points' | 'currentStep'>, 'name'>
export type OverlayCreate = ExcludePickPartial<Omit<Overlay, 'paneId' | 'currentStep' | 'totalStep' | 'defaultZLevel' | 'createPointFigures' | 'createXAxisFigures' | 'createYAxisFigures' | 'performEventPressedMove' | 'performEventMoveForDrawing'>, 'name'>
export type OverlayTemplate = ExcludePickPartial<Omit<Overlay, 'id' | 'groupId' | 'paneId' | 'points' | 'currentStep'>, 'name'>
export type OverlayCreate = ExcludePickPartial<Omit<Overlay, 'paneId' | 'currentStep' | 'totalStep' | 'createPointFigures' | 'createXAxisFigures' | 'createYAxisFigures' | 'performEventPressedMove' | 'performEventMoveForDrawing'>, 'name'>
export type OverlayRemove = Partial<Pick<Overlay, 'id' | 'groupId' | 'name'>>
export type OverlayInnerConstructor = new () => OverlayImp
export type OverlayConstructor = new () => Overlay
Expand All @@ -306,7 +301,6 @@ export default abstract class OverlayImp implements Overlay {
lock: boolean
visible: boolean
zLevel: number
defaultZLevel: number
mode: OverlayMode
modeSensitivity: number
points: Array<Partial<Point>> = []
Expand Down Expand Up @@ -397,14 +391,6 @@ export default abstract class OverlayImp implements Overlay {
return false
}

setDefaultZLevel (defaultZLevel: number): boolean {
if (this.defaultZLevel === undefined) {
this.defaultZLevel = defaultZLevel
return true
}
return false
}

setPaneId (paneId: string): void {
this.paneId = paneId
}
Expand Down Expand Up @@ -478,10 +464,6 @@ export default abstract class OverlayImp implements Overlay {
return false
}

resetZLevel (): void {
this.zLevel = this.defaultZLevel
}

setZLevel (zLevel: number): boolean {
if (this.zLevel !== zLevel) {
this.zLevel = zLevel
Expand Down
10 changes: 2 additions & 8 deletions src/store/OverlayStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export default class OverlayStore {

private _instances = new Map<string, OverlayImp[]>()

private readonly _counter = new Map<string, number>()

/**
* Overlay information in painting
*/
Expand Down Expand Up @@ -203,10 +201,10 @@ export default class OverlayStore {

private _sort (paneId?: string): void {
if (paneId !== undefined) {
this._instances.get(paneId)?.sort((o1, o2) => o1.defaultZLevel - o2.defaultZLevel).sort((o1, o2) => o1.zLevel - o2.zLevel)
this._instances.get(paneId)?.sort((o1, o2) => o1.zLevel - o2.zLevel).sort((o1, o2) => o1.zLevel - o2.zLevel)
} else {
this._instances.forEach(paneInstances => {
paneInstances.sort((o1, o2) => o1.defaultZLevel - o2.defaultZLevel).sort((o1, o2) => o1.zLevel - o2.zLevel)
paneInstances.sort((o1, o2) => o1.zLevel - o2.zLevel).sort((o1, o2) => o1.zLevel - o2.zLevel)
})
}
}
Expand All @@ -218,9 +216,6 @@ export default class OverlayStore {
const OverlayClazz = getOverlayInnerClass(overlay.name)
if (OverlayClazz !== null) {
const instance = new OverlayClazz()
const count = (this._counter.get(paneId) ?? 0) + 1
this._counter.set(paneId, count)
instance.setDefaultZLevel(count)
instance.setPaneId(paneId)
const groupId = overlay.groupId ?? id
overlay.id = id
Expand Down Expand Up @@ -431,7 +426,6 @@ export default class OverlayStore {
let sortFlag = false
if (instance !== null) {
sortFlag = true
instance.resetZLevel()
if (isFunction(instance.onMouseLeave)) {
instance.onMouseLeave({ overlay: instance, figureKey, figureIndex, ...event })
ignoreUpdateFlag = true
Expand Down

0 comments on commit ac27009

Please sign in to comment.