This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
local CollectionService = game:GetService("CollectionService") | ||
local automaticSize = require(script.Parent.automaticSize) | ||
|
||
local function hydrate(instance) | ||
local axisName = instance:GetAttribute("axis") | ||
|
||
automaticSize(instance, { | ||
maxSize = instance:GetAttribute("maxSize"), | ||
axis = if axisName then Enum.AutomaticSize[axisName] else nil, | ||
}) | ||
end | ||
|
||
--[=[ | ||
Applies automatic sizing to any current or future instances in the DataModel that are tagged with | ||
`"PlasmaAutomaticSize"`. Attributes `axis` (string) and `maxSize` (UDim2 or Vector2) are allowed. | ||
@within Plasma | ||
@tag utilities | ||
@client | ||
@return RBXScriptConnection | ||
]=] | ||
local function hydrateAutomaticSize() | ||
for _, instance in CollectionService:GetTagged("PlasmaAutomaticSize") do | ||
hydrate(instance) | ||
end | ||
|
||
return CollectionService:GetInstanceAddedSignal("PlasmaAutomaticSize"):Connect(function(instance) | ||
task.defer(hydrate, instance) -- instance added signal fires before children are added | ||
end) | ||
end | ||
|
||
return hydrateAutomaticSize |
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