Closed Vincz closed 6 years ago
Tons of thanks! I'll have a look and try to get this out tonight.
Hello again. I tried it now. The distribution based on centers seems to work, but the plugin does not ”remember” this setting, so the Distribute Again feature does not do the right thing after this kind of distribution. I am a bit too tired right now to fix this, but will do it later. Unless you feel up to it, of course. So, if you'd like to fix this, let me know. And if you don't have the time, let me know that as well, and I'll fix it.
Otherwise the PR looks good, and again I'd like to thank you for this help.
Hey! You're welcome for the help ! It's just a little contribution on you're amazing plugin :)
You are right, I forgot to handle the parameters restore.
I tried to implement it, but it doesn't work, and I have no idea why.
The parameters are restored properly, but if I run "Distribute again...", even if the checkbox wasn't check, it distributes from centers in a really weird way.
It's like this line doesn't work if centerSpacing
is false
[(Distributor.command) setValue:centerSpacing forKey:"distributorCenterSpacing" onLayer:Distributor.page];
I really don't get what is wrong with the repeat.
If you're able to tell me how I can debug the plugin (I'm really new to all of this), I can check. I just need to know where I can see the log of the log
function ^^
Thank you!
I am happy you are on it!
Sometimes I am able to see logs in the Console.app. I don’t remember the category, right now, but look for anything with bohemian.
There is a showMessage function in the Sketch API too. Even clunkier than logging, but anyway.
I tried it with your update now. Without having looked at the code (because in a hurry), I think the line you pointed out works. Since the dialogue does remember the setting between runs. But when using the repeat command it seems to always resolve to a truthy value… Strange. I will take a closer look later.
Alright, I checked the code out some now. It was somewhat like what I suspected, Distributor.centerSpacing
is an object which prints like 0
, but is truthy. I tried to do this in the var
section at the top of the distribute
function:
centerSpacing = centerSpacing + 0,
And then things start to work. It is not the most beautiful way to deal with it, but I'm pushing that change anyway…
I also added context
as the first argument to distribute
so that we can do context.document.showMessage()
, because the log shown in the Console.app no longer seem to work. (I should port this to skpm
so that the log is printed in the same terminal as the watcher runs. But that might take some work to do.)
Nice catch! Thank you!
Thank you! This PR added a lot of value to Distributor.
Hi! This PR add a checkbox to allow the spacing between the centers of objects instead of the edges. It's useful when you need to distribute objects of various sizes like the formerly "boxed" feature on Sketch Grid.