-- Set Pet Canvas Size --

function PetSrollingFrame:SetPetCanvasSize(Frame, searchOn)
	local UIGridLayout2 = Frame.UIGridLayout
	
	TradeMenuUI.Size = UDim2.new(0.55, 0, 0.925, 0)

	local PADDING, SIZE, MaxCells = getPetSizes()
	local AbsoluteSize = Frame.AbsoluteSize

	local NewPadding = PADDING * AbsoluteSize
	NewPadding = UDim2.new(0, NewPadding.X, 0, NewPadding.Y)
	local NewSize = SIZE * AbsoluteSize
	NewSize = UDim2.new(0, NewSize.X, 0, NewSize.Y)

	UIGridLayout2.CellPadding = NewPadding
	UIGridLayout2.CellSize = NewSize

	local children = Frame:GetChildren()
	local items = 0
	if searchOn == true then
		for _, v in pairs(Frame:GetChildren()) do
			if v:IsA("ImageLabel") and v:FindFirstChild("Data") then
				if v.Visible == true then
					items = items + 1
				end
			end
		end
	else
		items = (#children) - 1
	end
	local frameSizeY = Frame.AbsoluteSize.Y
	local ySize = UIGridLayout2.CellSize.Y.Offset
	local yPadding = UIGridLayout2.CellPadding.Y.Offset
	UIGridLayout2.FillDirectionMaxCells = MaxCells
	local rows = math.ceil(items / UIGridLayout2.FillDirectionMaxCells)
	local pixels = rows * ySize + (rows - 1) * yPadding
	Frame.CanvasSize = UDim2.new(0, 0, 0, (pixels + 5))

	if TradeMenuUI.Visible == false then
		TradeMenuUI.Size = UDim2.new(0, 0, 0, 0)
	end
end

return PetSrollingFrame
