You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using fabric.js 5.3.0 and I got to the following situation.
I try to align left some objects on the canvas (align to the most left of the active selection) using a specified gap between the selected objects.
When I am adding the gap between objects, I am iterating through the activeObjects (canvas.getActiveObjects()) and make some calculations to know how to update the top position for each object.
And here is where the problem is, I need the objects to not be sorted based on the order they've been added to the canvas, but I need them to keep the order in which they are displayed on the canvas.
For example if (1) I am adding to the canvas 3 shapes: a circle, a square and a rectangle and then (2) positioning them in another order - > rectangle -> circle below the rectangle -> square below the circle and then I am using (3) the alignment to the left with a specified gap, because of the order of the objects in canvas.getActiveObjects() I will have the objects in the order they've been added to the canvas (circle, square, rectangle) instead of the displayed order (rectangle, circle, square).
Is there another method to get the objects/the active objects of the canvas in the order they are actually displayed on the canvas?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am using fabric.js 5.3.0 and I got to the following situation.
I try to align left some objects on the canvas (align to the most left of the active selection) using a specified gap between the selected objects.
When I am adding the gap between objects, I am iterating through the activeObjects (canvas.getActiveObjects()) and make some calculations to know how to update the top position for each object.
And here is where the problem is, I need the objects to not be sorted based on the order they've been added to the canvas, but I need them to keep the order in which they are displayed on the canvas.
For example if (1) I am adding to the canvas 3 shapes: a circle, a square and a rectangle and then (2) positioning them in another order - > rectangle -> circle below the rectangle -> square below the circle and then I am using (3) the alignment to the left with a specified gap, because of the order of the objects in canvas.getActiveObjects() I will have the objects in the order they've been added to the canvas (circle, square, rectangle) instead of the displayed order (rectangle, circle, square).
Is there another method to get the objects/the active objects of the canvas in the order they are actually displayed on the canvas?
Thank you!
(1)
![image](https://private-user-images.githubusercontent.com/26135080/338843472-3fc8a602-6e02-4226-8a3a-445f892b5ccf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI5MzIzNDcsIm5iZiI6MTcyMjkzMjA0NywicGF0aCI6Ii8yNjEzNTA4MC8zMzg4NDM0NzItM2ZjOGE2MDItNmUwMi00MjI2LThhM2EtNDQ1Zjg5MmI1Y2NmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODA2VDA4MTQwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI0MDY1OGRmOWY4YTc3Nzg0NDQ5ZjZiNzlhZjJlZWU4Mjk4MDEyYmVmNTliNzQ2NDZjN2U0ZmM3NTkyMGE5OWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2dJpZCQmVi8GxC5JdPkImmauMTiU45DAkJaXBDLbDwg)
(2)
![image](https://private-user-images.githubusercontent.com/26135080/338843630-e153c6ce-c202-4093-9597-a0a11740910e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI5MzIzNDcsIm5iZiI6MTcyMjkzMjA0NywicGF0aCI6Ii8yNjEzNTA4MC8zMzg4NDM2MzAtZTE1M2M2Y2UtYzIwMi00MDkzLTk1OTctYTBhMTE3NDA5MTBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSU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dG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.fezyZppNX6wZcenurmAacWw3NIPhdSxBQoMHYXIfeeM)
Beta Was this translation helpful? Give feedback.
All reactions