lib-ScrollingTable

31 - SetScrollOffset patch

I needed to be able to set the scroll offset on-command so I wrote up a quick API for it:

local function SetScrollOffset(self, offset)
	local maxOffset = max(#self.filtered - self.displayRows, 0)
	if not offset or offset < 0 or offset > maxOffset then
		return -- invalid offset
	end
	
	local scrollPercent = offset / maxOffset
	local maxPixelOffset = self.scrollframe:GetVerticalScrollRange() + self.rowHeight
	local pixelOffset = scrollPercent * maxPixelOffset 
	self.scrollframe:SetVerticalScroll(pixelOffset)
	FauxScrollFrame_SetOffset(self.scrollframe, offset)
end

I left it up to the caller to make sure the offset was less than the maxOffset (as opposed to just setting it to the max if it isn't).

Thanks again! I'm using this library more and more now and really like how easily customizable it is (compared to AceGUI for example).

User When Change
sapu94 Sep 08, 2011 at 23:18 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • 3 comments
  • Avatar of sapu94 sapu94 Sep 09, 2011 at 19:49 UTC - 0 likes

    nvm seems to be working I just can't set the scroll to the last row immediately after adding more data for some reason so I just create a little timer and it works.

    Lead Developer and Director of TradeSkillMaster | @Sapu94 on Twitter

    "A good programmer is someone who always looks both ways before crossing a one-way street." Doug Linder

  • Avatar of sapu94 sapu94 Sep 09, 2011 at 19:31 UTC - 0 likes

    Hrm I'm having issues with this code this morning...I'll post back with an update when I figure them out.

  • Avatar of ddumont ddumont Sep 09, 2011 at 12:07 UTC - 0 likes

    Thanks! I'll try to get this included soon

  • 3 comments

Facts

Reported
Sep 08, 2011
Status
New - Issue has not had initial review yet.
Type
Patch - Source code patch for review
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees