From 42abf49b43adc2baad625220f341089c03278b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=96=E5=B4=96=E5=B4=96?= Date: Tue, 17 Dec 2019 19:17:57 +0800 Subject: [PATCH] feat(guide): ensure className and accessor for guide #41 --- packages/x6/src/handler/guide/guide.ts | 2 +- packages/x6/src/handler/guide/handler.ts | 4 +--- packages/x6/src/handler/guide/option.ts | 28 +++++++++++------------- packages/x6/src/index.less | 14 ++++++------ 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/packages/x6/src/handler/guide/guide.ts b/packages/x6/src/handler/guide/guide.ts index cfef4612a7a..be7047b313b 100644 --- a/packages/x6/src/handler/guide/guide.ts +++ b/packages/x6/src/handler/guide/guide.ts @@ -344,7 +344,7 @@ export class Guide extends Disposable { export namespace Guide { export interface Options { - getStrockStyle: (o: { + getStrockStyle: (args: { cell: Cell horizontal: boolean }) => { diff --git a/packages/x6/src/handler/guide/handler.ts b/packages/x6/src/handler/guide/handler.ts index 41ba1474ff0..8cec1c2437e 100644 --- a/packages/x6/src/handler/guide/handler.ts +++ b/packages/x6/src/handler/guide/handler.ts @@ -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), ) @@ -135,5 +135,3 @@ export class GuideHandler extends MouseHandler { this.reset() } } - -export namespace GuideHandler {} diff --git a/packages/x6/src/handler/guide/option.ts b/packages/x6/src/handler/guide/option.ts index 55323a4b6aa..afa963496ab 100644 --- a/packages/x6/src/handler/guide/option.ts +++ b/packages/x6/src/handler/guide/option.ts @@ -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 { @@ -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 @@ -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), } } @@ -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 } diff --git a/packages/x6/src/index.less b/packages/x6/src/index.less index 93309202782..52c5c0f4711 100644 --- a/packages/x6/src/index.less +++ b/packages/x6/src/index.less @@ -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