Skip to content

Commit

Permalink
2739/revert snapline sharp option deprecation (#2746)
Browse files Browse the repository at this point in the history
* fix: 🐛 re-enable alternative line style in snapline

* docs(snapline): 📚️ remove deprecation notice

* fix: 🐛 revert import order
  • Loading branch information
tonywu6 authored Oct 9, 2022
1 parent e09cb8c commit 2e066ab
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 56 deletions.
22 changes: 10 additions & 12 deletions packages/x6/src/addon/snapline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export class Snapline extends View implements IDisablable {

protected render() {
const container = (this.containerWrapper = new Vector('svg'))
const horizontal = (this.horizontal = new Vector('path'))
const vertical = (this.vertical = new Vector('path'))
const horizontal = (this.horizontal = new Vector('line'))
const vertical = (this.vertical = new Vector('line'))

container.addClass(this.containerClassName)
horizontal.addClass(this.horizontalClassName)
Expand Down Expand Up @@ -586,7 +586,10 @@ export class Snapline extends View implements IDisablable {
),
)
this.horizontal.setAttributes({
d: `M ${start.x},${start.y} L ${end.x},${end.y}`,
x1: this.options.sharp ? `${start.x}` : '0',
y1: `${start.y}`,
x2: this.options.sharp ? `${end.x}` : '100%',
y2: `${end.y}`,
display: 'inherit',
})
} else {
Expand All @@ -604,7 +607,10 @@ export class Snapline extends View implements IDisablable {
),
)
this.vertical.setAttributes({
d: `M ${start.x},${start.y} L ${end.x},${end.y}`,
x1: `${start.x}`,
y1: this.options.sharp ? `${start.y}` : '0',
x2: `${end.x}`,
y2: this.options.sharp ? `${end.y}` : '100%',
display: 'inherit',
})
} else {
Expand Down Expand Up @@ -661,14 +667,6 @@ export namespace Snapline {
enabled?: boolean
className?: string
tolerance?: number
/**
* @deprecated The behavior is now to clamp snaplines to the elements
* that are being aligned (instead of them spanning the entire graph),
* equivalent to `sharp: true`. The `sharp` option will be removed in a future release.
*
* @deprecated 对齐线将默认在对齐的元素边界截断,而不是跨越整个图的横轴/纵轴;相当于 `sharp: true`.
* `sharp` 选项将在之后的版本中去除。
*/
sharp?: boolean
/**
* Specify if snap on node resizing or not.
Expand Down
16 changes: 0 additions & 16 deletions packages/x6/src/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1882,36 +1882,20 @@ export class Graph extends Basecoat<EventArgs> {
return this
}

/**
* @deprecated
* @see Snapline.Options.sharp
*/
isSharpSnapline() {
return this.snapline.widget.options.sharp === true
}

/**
* @deprecated
* @see Snapline.Options.sharp
*/
enableSharpSnapline() {
this.snapline.widget.options.sharp = true
return this
}

/**
* @deprecated
* @see Snapline.Options.sharp
*/
disableSharpSnapline() {
this.snapline.widget.options.sharp = false
return this
}

/**
* @deprecated
* @see Snapline.Options.sharp
*/
toggleSharpSnapline(sharp?: boolean) {
if (sharp != null) {
if (sharp !== this.isSharpSnapline()) {
Expand Down
20 changes: 6 additions & 14 deletions sites/x6-sites/docs/tutorial/basic/snapline.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,9 @@ const graph = new Graph({
})
```

### ~~sharp~~
### sharp

~~是否显示截断的对齐线,默认为 `false`~~

[[error]]
| 在 1.32.7 及以上版本,`sharp` 选项将被废弃,不再生效。
|
| 在新版本中,默认行为将是显示截断的对齐线,等同于 1.32.7 以前的 `sharp: true`. [参见演示](#演示)
是否显示截断的对齐线,默认为 `false`

### resizing

Expand Down Expand Up @@ -223,34 +218,31 @@ toggleSnaplineOnResizing(enabled?: boolean): this
|---------|---------|:----:|--------|------------------------------------------|
| enabled | boolean | | - | 是否启用对齐线,缺省时切换对齐线的启用状态。 |

### ~~graph.isSharpSnapline()~~

[[error]]
| 在 1.32.7 及以上版本,`sharp` 选项将被废弃,不再生效,短款对齐线将成为默认效果。
### graph.isSharpSnapline()

```sign
isSharpSnapline(): boolean
```

是否使用短款对齐线。

### ~~graph.enableSharpSnapline()~~
### graph.enableSharpSnapline()

```sign
enableSharpSnapline(): this
```

启用短款对齐线,启用后对齐线只显示到相关节点位置处,否则显示贯穿画布的对齐线。

### ~~graph.disableSharpSnapline()~~
### graph.disableSharpSnapline()

```sign
disableSharpSnapline(): this
```

禁用短款对齐线,对齐线将贯穿整个画布。

### ~~graph.toggleSharpSnapline()~~
### graph.toggleSharpSnapline()

```sign
toggleSharpSnapline(enabled?: boolean): this
Expand Down
20 changes: 6 additions & 14 deletions sites/x6-sites/docs/tutorial/basic/snapline.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,9 @@ const graph = new Graph({
})
```

### ~~sharp~~
### sharp

~~是否显示截断的对齐线,默认为 `false`~~

[[error]]
| 在 1.32.7 及以上版本,`sharp` 选项将被废弃,不再生效。
|
| 在新版本中,默认行为将是显示截断的对齐线,等同于 1.32.7 以前的 `sharp: true`. [参见演示](#演示)
是否显示截断的对齐线,默认为 `false`

### resizing

Expand Down Expand Up @@ -223,34 +218,31 @@ toggleSnaplineOnResizing(enabled?: boolean): this
|---------|---------|:----:|--------|------------------------------------------|
| enabled | boolean | | - | 是否启用对齐线,缺省时切换对齐线的启用状态。 |

### ~~graph.isSharpSnapline()~~

[[error]]
| 在 1.32.7 及以上版本,`sharp` 选项将被废弃,不再生效,短款对齐线将成为默认效果。
### graph.isSharpSnapline()

```sign
isSharpSnapline(): boolean
```

是否使用短款对齐线。

### ~~graph.enableSharpSnapline()~~
### graph.enableSharpSnapline()

```sign
enableSharpSnapline(): this
```

启用短款对齐线,启用后对齐线只显示到相关节点位置处,否则显示贯穿画布的对齐线。

### ~~graph.disableSharpSnapline()~~
### graph.disableSharpSnapline()

```sign
disableSharpSnapline(): this
```

禁用短款对齐线,对齐线将贯穿整个画布。

### ~~graph.toggleSharpSnapline()~~
### graph.toggleSharpSnapline()

```sign
toggleSharpSnapline(enabled?: boolean): this
Expand Down

0 comments on commit 2e066ab

Please sign in to comment.