Skip to content

#1377 Show snap preview when drawing lines near stations#1379

Open
Unnamed2964 wants to merge 1 commit intorailmapgen:mainfrom
Unnamed2964:fix/1377
Open

#1377 Show snap preview when drawing lines near stations#1379
Unnamed2964 wants to merge 1 commit intorailmapgen:mainfrom
Unnamed2964:fix/1377

Conversation

@Unnamed2964
Copy link
Contributor

Implement #1377

When creating a line, if the pointer is within LINE_SNAP_RADIUS (20 SVG units) of a connectable node, the temporary line snaps to that station and a cyan circle indicator appears at the snap target.

  • Add LINE_SNAP_RADIUS constant in canvas.ts
  • Add snapTarget state and detection logic in handlePointerMove
  • Use cyan stroke for snap indicator consistent with snap lines
  • Use snapTarget in handlePointerUp to guarantee connection when visually snapped

…1377)

When creating a line, if the pointer is within LINE_SNAP_RADIUS (20 SVG units)
of a connectable node, the temporary line snaps to that station and a cyan
circle indicator appears at the snap target.

- Add LINE_SNAP_RADIUS constant in canvas.ts
- Add snapTarget state and detection logic in handlePointerMove
- Use cyan stroke for snap indicator consistent with snap lines
- Use snapTarget in handlePointerUp to guarantee connection when visually snapped
@Unnamed2964 Unnamed2964 changed the title feat: show snap preview when drawing lines near stations (#1377) #1377 feat: show snap preview when drawing lines near stations Mar 14, 2026
@Unnamed2964
Copy link
Contributor Author

1377-2.mp4

@Unnamed2964
Copy link
Contributor Author

1377-4.mp4

@thekingofcity
Copy link
Member

嗨,看起来效果不错,感谢您的贡献 :)

不过我比较在意但是如果20范围内有多个车站怎么办?以及如果一个车站大于等于20宽度,比如广州地铁换乘车站,效果又会怎样?

@Unnamed2964
Copy link
Contributor Author

Unnamed2964 commented Mar 14, 2026

如果大于20宽度,不会显示贴附效果,但如果在形状范围内仍然会连线,就像原有行为一样

@Unnamed2964
Copy link
Contributor Author

20范围内如果有多个车站,会选最近的车站

@Unnamed2964
Copy link
Contributor Author

Unnamed2964 commented Mar 14, 2026

如果大于20宽度,不会显示贴附效果,但如果在形状范围内仍然会连线,就像原有行为一样

这可能会给用户造成一定困扰(?)因为现在是显示贴附效果可以推出能够成功建立线段,但是成功建立线段不一定在创建时显示贴附效果。
但是我想rmp项目的连线是必须连接两个已有站点的,所以只是用户本来期望不会建立线段,但是发现建立了线段。

@Unnamed2964
Copy link
Contributor Author

Unnamed2964 commented Mar 14, 2026

有空的话我会测试一下那两种情况

@Unnamed2964
Copy link
Contributor Author

Unnamed2964 commented Mar 14, 2026

1377-6.mp4

@Unnamed2964
Copy link
Contributor Author

Unnamed2964 commented Mar 14, 2026

1377-8.mp4

@Unnamed2964
Copy link
Contributor Author

1377-6.mp4 的 json:
RMP_1773501562271.json

@Unnamed2964 Unnamed2964 changed the title #1377 feat: show snap preview when drawing lines near stations #1377 Show snap preview when drawing lines near stations Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants