Skip to content

Commit

Permalink
refactor: overlay => mask
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Dec 19, 2019
1 parent e028644 commit 1b407c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
46 changes: 23 additions & 23 deletions packages/x6/src/handler/handler-mouse.ts
Expand Up @@ -43,40 +43,40 @@ export abstract class MouseHandler<EventArgs = any>
e.consume()
}

private overlay: HTMLDivElement | null
addOverlay(cursor?: string | null) {
const overlay = util.createElement('div') as HTMLDivElement
overlay.style.position = 'absolute'
overlay.style.zIndex = '99999'
overlay.style.left = '0'
overlay.style.top = '0'
overlay.style.right = '0'
overlay.style.bottom = '0'
overlay.style.border = '0'
overlay.style.background = 'rgba(255, 255, 255, 0)'
this.overlay = overlay
this.setOverlayCursor(cursor)
document.body.appendChild(overlay)
private mask: HTMLDivElement | null
addMask(cursor?: string | null) {
const mask = util.createElement('div') as HTMLDivElement
mask.style.position = 'absolute'
mask.style.zIndex = '9999'
mask.style.left = '0'
mask.style.top = '0'
mask.style.right = '0'
mask.style.bottom = '0'
mask.style.border = '0'
mask.style.background = 'rgba(255, 255, 255, 0)'
this.mask = mask
this.setMaskCursor(cursor)
document.body.appendChild(mask)
}

removeOverlay() {
util.removeElement(this.overlay)
this.overlay = null
removeMask() {
util.removeElement(this.mask)
this.mask = null
}

getOverlayCursor() {
return this.overlay ? this.overlay.style.cursor : null
getMaskCursor() {
return this.mask ? this.mask.style.cursor : null
}

setOverlayCursor(cursor?: string | null) {
if (this.overlay) {
this.overlay.style.cursor = cursor == null ? '' : cursor
setMaskCursor(cursor?: string | null) {
if (this.mask) {
this.mask.style.cursor = cursor == null ? '' : cursor
}
}

private savedBodyCursor: string
private savedContainerCursor: string
setGlobalCursor(cursor: string | null | undefined) {
setGlobalCursor(cursor?: string | null) {
this.savedBodyCursor = document.body.style.cursor
this.savedContainerCursor = this.graph.container.style.cursor
document.body.style.cursor = cursor || ''
Expand Down
4 changes: 2 additions & 2 deletions packages/x6/src/handler/node/handler.ts
Expand Up @@ -59,7 +59,7 @@ export class NodeHandler extends MouseHandler {
const ret = this.knobs.getHandle(e)
if (ret != null) {
this.start(e.getGraphX(), e.getGraphY(), ret.index)
this.addOverlay(ret.cursor)
this.addMask(ret.cursor)
e.consume()
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ export class NodeHandler extends MouseHandler {

e.consume()

this.removeOverlay()
this.removeMask()
this.reset()
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/x6/src/handler/node/preview.ts
Expand Up @@ -748,7 +748,7 @@ export class Preview extends Disposable {

protected updateOverlayCursor(e: MouseEventEx) {
if (this.overlayCursor == null) {
this.overlayCursor = this.master.getOverlayCursor()
this.overlayCursor = this.master.getMaskCursor()
}

const oldBounds = this.getStateBounds()
Expand Down Expand Up @@ -833,7 +833,7 @@ export class Preview extends Disposable {
}
}

this.master.setOverlayCursor(cursor)
this.master.setMaskCursor(cursor)
}

hasRotated() {
Expand Down

0 comments on commit 1b407c4

Please sign in to comment.