added scrollbar ScrollTo method for direct positioning

This commit is contained in:
Stepets 2014-10-25 14:35:45 +04:00
parent fcf09d6618
commit 334ce1b2c7

View File

@ -329,6 +329,44 @@ function newobject:Scroll(amount)
end
--[[---------------------------------------------------------
- func: ScrollTo(position)
- desc: scrolls the object
--]]---------------------------------------------------------
function newobject:ScrollTo(position)
local bartype = self.bartype
local listo = self.parent.parent.parent
local onscroll = listo.OnScroll
if bartype == "vertical" then
local denormalized = position * self.maxy
local newy = denormalized + self.parent.y
if newy > self.maxy then
self.staticy = self.maxy - self.parent.y
elseif newy < self.parent.y then
self.staticy = 0
else
self.staticy = denormalized
end
elseif bartype == "horizontal" then
local denormalized = position * self.maxx
local newx = denormalized + self.parent.x
if newx > self.maxx then
self.staticx = self.maxx - self.parent.x
elseif newx < self.parent.x then
self.staticx = 0
else
self.staticx = denormalized
end
end
if onscroll then
onscroll(listo)
end
end
--[[---------------------------------------------------------
- func: IsDragging()
- desc: gets whether the object is being dragged or not