function init(J)local M=J.Frame local o=M.Dragger local G=M.Background local A=J._Axis local R=J._Maid local w=J._Spring local d=Lazy.Classes.Dragger.new(o)J.DragStart=d.DragStart J.DragStop=d.DragStop R:Mark(M)R:Mark(J._ChangedBind)R:Mark(J._ClickedBind)R:Mark(function()d:Destroy()end)local function K(J,M)if A=="\121"then J,M=M,J end return UDim2.new(J,0,M,0)end local I=-1 local h,B local function Q()h,B=getBounds(J)G.Size=K(B/M.AbsoluteSize[A],1)I=-1 end Q()R:Mark((M:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\083\105\122\101")):Connect(Q))R:Mark((M:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\080\111\115\105\116\105\111\110")):Connect(Q))R:Mark((M:GetPropertyChangedSignal("\080\097\114\101\110\116")):Connect(Q))local m=0 local D=0 local g=false R:Mark(o.SelectionGained:Connect(function()g=true end))R:Mark(o.SelectionLost:Connect(function()g=false end))R:Mark(UIS.InputChanged:Connect(function(J,M)if M and J.KeyCode==THUMBSTICK then local M=J.Position m=math.abs(M[A])>XBOX_DEADZONE and math.sign(M[A])or 0 end end))R:Mark(d.DragChanged:Connect(function(M,o,G)if J.IsActive then J:Set((o.Position[A]-h)/B,false)end end))R:Mark(M.InputBegan:Connect(function(M)if M.UserInputType==Enum.UserInputType.MouseButton1 or M.UserInputType==Enum.UserInputType.Touch then local o=(M.Position[A]-h)/B J._ClickedBind:Fire(math.clamp(o,0,1))if J.IsActive then J:Set(o,J.TweenClick)end end end))R:Mark(RUNSERVICE.RenderStepped:Connect(function(G)if g then local M=tick()if J.Interval<=0 then J:Set(J:Get()+((m*XBOX_STEP)*G)*60)elseif M-D>DEBOUNCE_TICK then D=M J:Set(J:Get()+J.Interval*m)end end w:Update(G)local R=w.x if R~=I then local G=((h+R*B)-M.AbsolutePosition[A])/M.AbsoluteSize[A]o.Position=K(G,.5)J._ChangedBind:Fire(J:Get())I=R end end))end function getBounds(J)local M=J.Frame local o=M.Dragger local G=J._Axis local A=M.AbsolutePosition[G]+o.AbsoluteSize[G]/2 local R=M.AbsoluteSize[G]-o.AbsoluteSize[G]return A,R end
-- Private Methods

function init(self)
	local frame = self.Frame
	local dragger = frame.Dragger
	local background = frame.Background

	local axis = self._Axis
	local maid = self._Maid
	local spring = self._Spring
	local dragTracker = Lazy.Classes.Dragger.new(dragger)

	self.DragStart = dragTracker.DragStart
	self.DragStop = dragTracker.DragStop

	maid:Mark(frame)
	maid:Mark(self._ChangedBind)
	maid:Mark(self._ClickedBind)
	maid:Mark(function()
		dragTracker:Destroy()
	end)

	-- Get bounds and background size scaled accordingly for calculations
	local function setUdim2(a, b)
		if axis == "y" then
			a, b = b, a
		end
		return UDim2.new(a, 0, b, 0)
	end

	local last = -1
	local bPos, bSize
	local function updateBounds()
		bPos, bSize = getBounds(self)
		background.Size = setUdim2(bSize / frame.AbsoluteSize[axis], 1)
		last = -1
	end

	updateBounds()
	maid:Mark(frame:GetPropertyChangedSignal("AbsoluteSize"):Connect(updateBounds))
	maid:Mark(frame:GetPropertyChangedSignal("AbsolutePosition"):Connect(updateBounds))
	maid:Mark(frame:GetPropertyChangedSignal("Parent"):Connect(updateBounds))

	-- Move the slider when the xbox moves it
	local xboxDir = 0
	local xboxTick = 0
	local xboxSelected = false

	maid:Mark(dragger.SelectionGained:Connect(function()
		xboxSelected = true
	end))

	maid:Mark(dragger.SelectionLost:Connect(function()
		xboxSelected = false
	end))

	maid:Mark(UIS.InputChanged:Connect(function(input, process)
		if process and input.KeyCode == THUMBSTICK then
			local pos = input.Position
			xboxDir = math.abs(pos[axis]) > XBOX_DEADZONE and math.sign(pos[axis]) or 0
		end
	end))

	-- Move the slider when we drag it
	maid:Mark(dragTracker.DragChanged:Connect(function(element, input, delta)
		if self.IsActive then
			self:Set((input.Position[axis] - bPos) / bSize, false)
		end
	end))

	-- Move the slider when we click somewhere on the bar
	maid:Mark(frame.InputBegan:Connect(function(input)
		if
			input.UserInputType == Enum.UserInputType.MouseButton1
			or input.UserInputType == Enum.UserInputType.Touch
		then
			local t = (input.Position[axis] - bPos) / bSize
			self._ClickedBind:Fire(math.clamp(t, 0, 1))
			if self.IsActive then
				self:Set(t, self.TweenClick)
			end
		end
	end))

	-- position the slider
	maid:Mark(RUNSERVICE.RenderStepped:Connect(function(dt)
		if xboxSelected then
			local t = tick()
			if self.Interval <= 0 then
				self:Set(self:Get() + xboxDir * XBOX_STEP * dt * 60)
			elseif t - xboxTick > DEBOUNCE_TICK then
				xboxTick = t
				self:Set(self:Get() + self.Interval * xboxDir)
			end
		end

		spring:Update(dt)
		local x = spring.x
		if x ~= last then
			local scalePos = (bPos + (x * bSize) - frame.AbsolutePosition[axis]) / frame.AbsoluteSize[axis]
			dragger.Position = setUdim2(scalePos, 0.5)
			self._ChangedBind:Fire(self:Get())
			last = x
		end
	end))
end

function getBounds(self)
	local frame = self.Frame
	local dragger = frame.Dragger
	local axis = self._Axis

	local pos = frame.AbsolutePosition[axis] + dragger.AbsoluteSize[axis] / 2
	local size = frame.AbsoluteSize[axis] - dragger.AbsoluteSize[axis]

	return pos, size
end
