-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(): Extended New Snapping Guidelines for objects #8955
feat(): Extended New Snapping Guidelines for objects #8955
Conversation
@CODE-AXION thank you for the PR! I will back to you soon |
…e.js also fixed a bug when downloading the canvas to different formats so added some conditions on canvas:before render code part .
f89a1d6
to
8ae87d2
Compare
@asturur |
@asturur Hi its been a long time can you review this PR ? |
Build Stats
|
Those will need to be updated to TS and exported properly for v6, but i see no harm in merging as is. |
This is the feature I am very interested in |
Not sure, but if it doesn't it should pretty easy to fix. |
You have also to consider this code hasn't been tested with v6 and more importantly has no tests at all |
: (activeObjectTop - activeObjectHeight / 2 - aligningLineOffset) | ||
}); | ||
|
||
activeObject.setPositionByOrigin(new fabric.Point(objectLeft - objectWidth / 2 - activeObjectWidth / 2, activeObjectTop), 'center', 'center'); |
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.
do not use setPositionByOrigin, it is wrong for a nested object
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.
use setXY since the point is in the scene
|
||
verticalInTheRange = true; | ||
verticalLines.push({ | ||
x: objectLeft - objectWidth / 2, |
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.
objectLeft is a wrong name
if (canvas.contextTop) { | ||
canvas.clearContext(canvas.contextTop); | ||
} |
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.
not needed if v6
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.
the right approach would be
canvas.contextTopDirty = true
When this is merged I could help with conversion to typescript, since I need it for my fabric project where I use v6 beta, I have to convert it to typescript anyway to be able to use it. |
@ShaMan123 This code won't probably work with nested selections inside groups, but also it wasn't in scope at the time of changes. It hasn't been reviewed for ages and i m not going to ask changes now isn't really helpful. |
The real issue with this code is that it assumes that there is an object called 'fabric' that doesn't exist in that context. |
@Smrtnyk i suggest you do not dive converting this exact code in TS. scaling support I hope we can close 6.0 soon and then fit this in a roadmap with some specs, then if you think you can take it on, you can take it on, with specs |
@CODE-AXION on which version of fabricJS are you using this exact code? |
@asturur ok so i opened the project on my local and at that time i was using "version": "6.0.0-beta6" (from package.json) |
So it works for you also if it references fabric.Point? do you have fabric object on the window object? |
@asturur yes i am using fabric on the window object |
@CODE-AXION someone refactored all the guidelines in TS and i worked to make them an extension package in fabric. |
1) The feature was added using the existing code methods mentioned in aligning_guidelines.js file
New Features I Added In Snapping Guidelines:
Existing Snapping Guidelines:
New Snapping Guidelines screenshots:
snaps if the left side of the active object touches the right side of the other object:
snaps if the right side of the active object touches the left side of the other object
snaps if the top of the active object touches the bottom of the other object:
snaps if the bottom of the active object touches the top of the other object:
2) Fixed a bug
bug: Throws an error when i try to download the canvas in different formats like png , jpg etc..
How i fixed: added condition check on lib/centering_guidelines.js and lib/aligning_guidelines.js
Error: