-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
feat: editable element stats #6382
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
|
@ryan-di what about adding Code: function greatestCommonDenominator(a: number, b: number): number {
if (b === 0) {
return a;
}
return greatestCommonDenominator(b, a % b);
}
function isMaxTwoDigit(a: number) {
return a >= 1 && a <= 99;
}
function findRatioOrFraction(width: number, height: number) {
// round because with excalidraw's imprecise bounding box, even in grid mode,
// coupled with floating point rounding errors, we'd rarely get a perfect
// aspect ratio
width = Math.round(width);
height = Math.round(height);
const greatestCommonDivisor = greatestCommonDenominator(width, height);
const simplifiedWidth = Math.round(width / greatestCommonDivisor);
const simplifiedHeight = Math.round(height / greatestCommonDivisor);
// we want to display in W:H format only if both W and H are <= 2 digits
if (isMaxTwoDigit(simplifiedWidth) && isMaxTwoDigit(simplifiedHeight)) {
return `${simplifiedWidth}:${simplifiedHeight}`;
}
return (width / height).toPrecision(3);
}<tr>
<td>Aspect ratio</td>
<td>
{findRatioOrFraction(
selectedBoundingBox[2] - selectedBoundingBox[0],
selectedBoundingBox[3] - selectedBoundingBox[1],
)}
</td>
</tr>What's left to figure out is how editing works.
|
|
Hi! :) Any news on this? Can this be picked up or is this not good anymore? |
|
We initially hit some roadblocks that required more changes/refactor elsewhere. Should be more or less unblocked now, though we bumped down in priority. We may restart the effort soon. @ryan-di if we align the width/height change behavior with the behavior from side-resizing, that should simplify things a lot. Were there any other issues you were facing? |
|
@dwelle there was also a lack of geometric helpers iirc. Agree with you that we should be a in a much better position to pick this up without much resistance 👍 |
|
Nice, thanks @ryan-di @dwelle . Actually for us Radius change would be the most important as that's the only property from the ones mentioned that can't be changed from UI. Huge plus if there's an option to change each 4 corners separately. I would say there's no need implement the drag pointer like in figma, a simple number text/number input would be enough for most users. Right now we have to use a rectangle and two circles to do rouned rectangles. Very difficult to use bc you can't have a stroke, and can't change height/width dynamically.
|
|
Todos:
|
815cb00 to
ae42659
Compare
so we don't need to keep a migration from `boolean` to init the defaults
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.
🚀
|
When will this be available as part of npm package. |


fix #5932
First, we will remove element stats from "stats for nerds" (which gets renamed to "general stats") and will be placed into its own panel/island. The rationale behind is that elements stats are more individual. Moreover, it's now interactive, meaning an element's shape and location can be edited from the element stats panel/island.
Apart from the previously available summary of the scene, we've added an additional section, Element properties. The idea behind this is to allow users to change some of the properties more easily and more accurately.
For now, there are at most six properties to be displayed:
For individual elements, the displayed properties are the ones that can be edited.
And for group / multiple elements,
We've built a Figma like drag input to allow the user to control how the value is changed. The drag is activated when the pointer is over the "icon" part of the input as can be seen here:
Figma did a really great job with the numeric input, where the pointer gets wrapped, much like the game Snake.
Todos
next PRs