Last active
December 28, 2023 20:12
-
-
Save robkamp/fac2b2d80ee44e7085c70738de544341 to your computer and use it in GitHub Desktop.
#jArchi AlignHorizontally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: Rob Kamp | |
// Requires: jArchi - https://www.archimatetool.com/blog/2018/07/02/jarchi/ | |
// Purpose: Align to lowest, spread the selected elements horizontally, and resize to be equal size | |
// Date: 2019-11-20 | |
// Version 1.0 | |
// Change: Initial version | |
console.log("Start: Spread and Align horizontally"); | |
minY = null; | |
minX = null; | |
maxWidth = 0; | |
maxHeight = 0; | |
// Determine the width, height, and | |
$(selection).each(function(element) { | |
minY = Math.min(element.bounds.y,minY==null?element.bounds.y:minY); | |
minX = Math.min(element.bounds.x,minX==null?element.bounds.x:minX); | |
maxWidth = Math.max(element.bounds.width,maxWidth); | |
maxHeight = Math.max(element.bounds.height,maxHeight); | |
}); | |
// Sort the selection so the order stays the same | |
$(selection).sort(function (left,right) { | |
return left.bounds.x-right.bounds.x; | |
}); | |
// Walk throught the sorted selection | |
$(selection).each(function (element) { | |
// Set the new bounds | |
element.bounds = {x: minX, y: minY, width: maxWidth, height: maxHeight}; | |
// Set the spacing for the next element | |
minX = minX + maxWidth + 20; | |
}); | |
console.log("End: Spread and Align horizontally"); |
It's working well.
Thank you.
Thanks ! very handy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, very helpful.