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 |
- 3 comments
- 3 comments
- Reply
- #3
sapu94 Sep 09, 2011 at 19:49 UTC - 0 likesnvm 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
- Reply
- #2
sapu94 Sep 09, 2011 at 19:31 UTC - 0 likesHrm I'm having issues with this code this morning...I'll post back with an update when I figure them out.
- Reply
- #1
ddumont Sep 09, 2011 at 12:07 UTC - 0 likesThanks! I'll try to get this included soon