-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas: Add snapping to vertex edit #84417
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM! Great job on the vertex work!! It is super fun to play around with :)
const angleOverall = calculateAngle(vx1, vy1, vx2, vy2); | ||
const angleBefore = calculateAngle(vx1, vy1, x, y); | ||
deleteVertex = Math.abs(angleBefore - angleOverall) < CONNECTION_VERTEX_SNAP_TOLERANCE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit but this logic might be good to clean up and put into a separate func
@@ -275,6 +281,8 @@ export class Connections { | |||
|
|||
// Handles mousemove and mouseup events when dragging an existing vertex | |||
vertexListener = (event: MouseEvent) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be done later after G11 cutoff but we might want to consider breaking out vertex logic into separate file maybe 🤔
|
||
if (deleteVertex) { | ||
// Display temporary vertex removal | ||
this.scene.selecto!.rootContainer!.style.cursor = 'not-allowed'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the cursor style change there to indicate that the vertexes are being removed? I'm not sure this is necessary (i.e. end user probably doesn't care if vertexes are being removed and just care about ending line) / might be confusing to end user as it seems like they are doing an action that isn't allowed or something 🤔
Screen.Recording.2024-03-18.at.9.02.12.PM.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to agree here, feels like this cursor doesn't quite match up with the outcome expected. Maybe would be better to have a treatment for the line or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, appreciate having more eyes on this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great that we have snapping. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! See my comment regaring deletion 😄
@@ -18,6 +19,11 @@ import { | |||
import { CONNECTION_ANCHOR_ALT, ConnectionAnchors, CONNECTION_ANCHOR_HIGHLIGHT_OFFSET } from './ConnectionAnchors'; | |||
import { ConnectionSVG } from './ConnectionSVG'; | |||
|
|||
export const CONNECTION_VERTEX_ID = 'vertex'; | |||
export const CONNECTION_VERTEX_ADD_ID = 'vertexAdd'; | |||
const CONNECTION_VERTEX_ORTHO_TOLERANCE = 0.05; // Cartesian ratio against vertical or horizontal tolerance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely use of constants ❤️
|
||
if (deleteVertex) { | ||
// Display temporary vertex removal | ||
this.scene.selecto!.rootContainer!.style.cursor = 'not-allowed'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to agree here, feels like this cursor doesn't quite match up with the outcome expected. Maybe would be better to have a treatment for the line or something like that?
Add snapping to vertex edit of connections in canvas.
Disable snapping using control key:
![Mar-15-2024 15-20-04](https://private-user-images.githubusercontent.com/60050885/313347433-6df6994f-5657-4a31-a4ff-a1afa283c8d1.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyNTgwMDEsIm5iZiI6MTcyMDI1NzcwMSwicGF0aCI6Ii82MDA1MDg4NS8zMTMzNDc0MzMtNmRmNjk5NGYtNTY1Ny00YTMxLWE0ZmYtYTFhZmEyODNjOGQxLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA2VDA5MjE0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY5N2Q4NjEwYjI1MTI4NmIwZmI2MmE2YWE5YTNjZjBiZmZiYjdhZjI1ZDY0MTdkZTlkN2NiMWU2YjVlNWIyNWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.J9unb-RJkH-t9wS0Un2kpufHwHEJpGpj_jGSznOwwVQ)
Snapping during vertex creation:
![Mar-15-2024 15-19-31](https://private-user-images.githubusercontent.com/60050885/313347421-fb75a005-39b2-4ae1-802c-825bcf512910.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyNTgwMDEsIm5iZiI6MTcyMDI1NzcwMSwicGF0aCI6Ii82MDA1MDg4NS8zMTMzNDc0MjEtZmI3NWEwMDUtMzliMi00YWUxLTgwMmMtODI1YmNmNTEyOTEwLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA2VDA5MjE0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTY0NDllM2UxZjQ1ZjQwNDg4ZWYwM2I5MWQyNzU0NjdmZGIyOTAzZTE2YmZhMmU0OGRjMTg2ZDBkMmJhZTgzOGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9xde35UIxiB2quEsPrHO5JuN8O_KajzsJHPfmak4q48)
Horizontal and vertical snap during vertex edit:
![Mar-13-2024 22-14-16](https://private-user-images.githubusercontent.com/60050885/312708202-30dc9ebb-2682-4f33-bbdf-0cceb69e7fb5.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyNTgwMDEsIm5iZiI6MTcyMDI1NzcwMSwicGF0aCI6Ii82MDA1MDg4NS8zMTI3MDgyMDItMzBkYzllYmItMjY4Mi00ZjMzLWJiZGYtMGNjZWI2OWU3ZmI1LmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA2VDA5MjE0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTExZTZjMjFkMWJiOThlNmM0MTM2MDZiYTA3NmE3ODhhNjI3ZGFkZDg3YWRjMDYxMWVjY2U3ODU5OGVhNjI2M2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.aiJ4f-xbyK837uykI_YQsmtz2E8jrmTPFul_lmTb1Lk)
Deleting a vertex:
![Mar-13-2024 15-16-06](https://private-user-images.githubusercontent.com/60050885/312640870-124fb368-e64d-43dc-812e-d45c02200127.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyNTgwMDEsIm5iZiI6MTcyMDI1NzcwMSwicGF0aCI6Ii82MDA1MDg4NS8zMTI2NDA4NzAtMTI0ZmIzNjgtZTY0ZC00M2RjLTgxMmUtZDQ1YzAyMjAwMTI3LmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA2VDA5MjE0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZkMDQ2MDg5NTA5NDBjN2MwZDkxZDg1ZTM0ZjZiYzNmNDk2NGQyMTVkYTAzNmJjMDlkYzc3ZDcxMTM0NDQ4YTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.IcWxQPdUyLgmaxem3YwT8DyFle0IHoeDYEfLTlRYf3M)
Closes #83269