Ok so I wanted to come back to this thing. The adding of info frames and placement of everything works nicely. Problem is that its still lagging. Getting around 50 fps.
local List = {}
local ReplicatedStorage = game.ReplicatedStorage
local UIGridLayout = script.Parent.Nest.UIGridLayout
local HTTPSService = game:GetService("HttpService")
local ScrollingFrame = script.Parent
local Nest = script.Parent.Nest
local NewlyVisibleFrames = {}
local PreviouslyVisible = {}
--- ... later in the script...
function UpdateNest()
Nest.Size = UDim2.new(Nest.Size.X.Scale, 0, 0, UIGridLayout.AbsoluteContentSize.Y)
end
function UpdateCanvasSize()
ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, UIGridLayout.AbsoluteContentSize.Y)
end
function update_visible_frames(AmmountInTable)
local CellPaddingY = UIGridLayout.CellPadding.Y.Offset
local TopCanvasPosition = Nest.AbsolutePosition.Y
local TopWindowPosition = ScrollingFrame.AbsolutePosition.Y
local TopOfficialSize = (TopWindowPosition-TopCanvasPosition)
local FrameYTop = math.floor((TopOfficialSize/(UIGridLayout.AbsoluteCellSize.Y+UIGridLayout.CellPadding.Y.Offset))*UIGridLayout.AbsoluteCellCount.X + .5)
local AmmountInWindow = math.floor((ScrollingFrame.AbsoluteSize.Y/(UIGridLayout.AbsoluteCellSize.Y+UIGridLayout.CellPadding.Y.Offset))*UIGridLayout.AbsoluteCellCount.X + .5)
FrameYTop = math.clamp(FrameYTop-UIGridLayout.AbsoluteCellCount.X, 0, 2e9)
local FrameYBottom = (FrameYTop + AmmountInWindow)+(UIGridLayout.AbsoluteCellCount.X*2)
if FrameYBottom > AmmountInTable then
FrameYBottom = AmmountInTable
end
PreviouslyVisible = NewlyVisibleFrames
NewlyVisibleFrames = {}
for i = FrameYTop, FrameYBottom do
if List[i] then
local Frame = List[i]
local find = table.find(PreviouslyVisible, Frame)
if find then
table.remove(PreviouslyVisible, find)
end
if not Frame:FindFirstChildOfClass("Folder") then
ReplicatedStorage.Info:Clone().Parent = Frame
end
table.insert(NewlyVisibleFrames, Frame)
--print(Frame)
--print(NewlyVisibleFrames)
end
end
for i, v in pairs(PreviouslyVisible) do
if v:FindFirstChildOfClass("Folder") then
v.Info:Destroy()
end
end
end
local Entrys = 10000
for i = 1, Entrys do
local clone = script.Template:Clone()
clone.Name = HTTPSService:GenerateGUID(false)
clone.Parent = ScrollingFrame.Nest
table.insert(List, clone)
--if i % (math.ceil(Entrys*1)) == 0 or i == 1 then
--PilesOfLists[#PilesOfLists+1] = {}
--end
--table.insert(PilesOfLists, HttpService:GenerateGUID(false))
end
function UpdateAll()
--UpdateScrollingFrame()
UpdateNest()
UpdateCanvasSize()
update_visible_frames(#List)
end
UpdateAll()
ScrollingFrame:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
update_visible_frames(#List)
end)
ScrollingFrame:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
UpdateAll()
--UpdateNest()
--UpdateScrollingFrame()
--update_visible_frames(#List)
--UpdateUIGridLayout()
end)