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

	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(frame.SelectionGained:Connect(function()
		xboxSelected = true
	end))

	maid:Mark(frame.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
