Skip to content

Commit

Permalink
feat(guide): ensure className and accessor for guide
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Dec 19, 2019
1 parent 2501100 commit 42abf49
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/x6/src/handler/guide/guide.ts
Expand Up @@ -344,7 +344,7 @@ export class Guide extends Disposable {

export namespace Guide {
export interface Options {
getStrockStyle: (o: {
getStrockStyle: (args: {
cell: Cell
horizontal: boolean
}) => {
Expand Down
4 changes: 1 addition & 3 deletions packages/x6/src/handler/guide/handler.ts
Expand Up @@ -28,8 +28,8 @@ export class GuideHandler extends MouseHandler {

mouseDown(e: MouseEventEx) {
if (movment.isValid(this, e) && movment.canMove(this, e)) {
this.origin = util.clientToGraph(this.graph.container, e)
this.cell = this.getCell(e)!
this.origin = util.clientToGraph(this.graph.container, e)
this.bounds = this.graph.view.getBounds(
movment.getCells(this, this.cell, e),
)
Expand Down Expand Up @@ -135,5 +135,3 @@ export class GuideHandler extends MouseHandler {
this.reset()
}
}

export namespace GuideHandler {}
28 changes: 13 additions & 15 deletions packages/x6/src/handler/guide/option.ts
Expand Up @@ -38,9 +38,9 @@ export interface IsGuideEnabledArgs {
e: MouseEvent
}

export function isGuideEnabled(o: IsGuideEnabledArgs) {
const guide = o.graph.options.guide as GuideOptions
return drill(guide.enabled, o.graph, o)
export function isGuideEnabled(args: IsGuideEnabledArgs) {
const guide = args.graph.options.guide
return drill(guide.enabled, args.graph, args)
}

export interface GetGuideStyleArgs {
Expand All @@ -49,10 +49,10 @@ export interface GetGuideStyleArgs {
horizontal: boolean
}

function getGuideStrockStyle(o: GetGuideStyleArgs) {
const graph = o.graph
const options = o.graph.options.guide as GuideOptions
const sub = (o.horizontal
function getGuideStrockStyle(args: GetGuideStyleArgs) {
const graph = args.graph
const options = graph.options.guide
const sub = (args.horizontal
? options.horizontal
: options.vertical) as GuideSubOptions

Expand All @@ -63,10 +63,10 @@ function getGuideStrockStyle(o: GetGuideStyleArgs) {
const className = sub.className != null ? sub.className : options.className

return {
dashed: drill(dashed, graph, o),
stroke: drill(stroke, graph, o),
strokeWidth: drill(strokeWidth, graph, o),
className: drill(className, graph, o),
dashed: drill(dashed, graph, args),
stroke: drill(stroke, graph, args),
strokeWidth: drill(strokeWidth, graph, args),
className: drill(className, graph, args),
}
}

Expand All @@ -80,12 +80,10 @@ export function createGuide(graph: Graph, states: State[]) {
})

guide.rounded = options.rounded

guide.horizontal =
horizontal && horizontal.enabled != null ? horizontal.enabled : true

horizontal != null && horizontal.enabled != null ? horizontal.enabled : true
guide.vertical =
vertical && vertical.enabled != null ? vertical.enabled : true
vertical != null && vertical.enabled != null ? vertical.enabled : true

return guide
}
14 changes: 7 additions & 7 deletions packages/x6/src/index.less
Expand Up @@ -15,21 +15,21 @@
.@{prefix}-label {
}

.@{prefix}-guide {
}
// #region handlers

.@{prefix}-guide.horizontal {
.@{prefix}-rubberband {
}

.@{prefix}-guide.vertical {
.@{prefix}-cell-selected {
}

// #region handlers
.@{prefix}-guide {
}

.@{prefix}-rubberband {
.@{prefix}-guide.horizontal {
}

.@{prefix}-cell-selected {
.@{prefix}-guide.vertical {
}

// #endregion

0 comments on commit 42abf49

Please sign in to comment.