Thread: Fix over scroll
View Single Post
01-05-24, 09:07 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 237
Fix over scroll

Hi all

I have a bear-bones scroll set up that is over-scrolling past the last data button.


Here is my code:
Lua Code:
  1. local function updateScrollFrame()
  2.     FauxScrollFrame_Update(
  3.         TestScrollFrame,
  4.         #TestData,
  5.         7,
  6.         20
  7.     )
  8.     for index = 1, 7 do
  9.         local offset = index + FauxScrollFrame_GetOffset(TestScrollFrame)
  10.         local button = TestScrollFrame.buttons[index]
  11.         button:SetNormalFontObject(NumberFontNormalLargeYellow)
  12.         button:SetHighlightFontObject(NumberFontNormalLargeYellow)
  13.         button.index = offset
  14.         if offset <= #TestData then
  15.             button:SetText(TestData[offset])
  16.             button:Show()
  17.         else
  18.             button:Hide()
  19.         end
  20.     end
  21. end
  22.  
  23. local TestScrollFrame = CreateFrame("Frame", "TestScrollFrame", TestInterfaceFrame, "ChatConfigBoxTemplate")
  24. TestScrollFrame:SetSize(500, 150)
  25. TestScrollFrame:SetPoint("TOPLEFT", TestInterfaceFrame, "BOTTOMLEFT")
  26.  
  27. local TestScrollFrame =
  28.     CreateFrame("ScrollFrame", "TestScrollFrame", TestScrollFrame, "FauxScrollFrameTemplate")
  29. TestScrollFrame:SetPoint("TOPLEFT", 0, -8)
  30. TestScrollFrame:SetPoint("BOTTOMRIGHT", -30, 8)
  31. TestScrollFrame:SetScript(
  32.     "OnVerticalScroll",
  33.     function(self, offset)
  34.         FauxScrollFrame_OnVerticalScroll(self, offset, 7, updateScrollFrame)
  35.     end
  36. )
  37.  
  38. TestScrollFrame.buttons = {}
  39. for index = 1, 7 do
  40.     TestScrollFrame.buttons[index] =
  41.         CreateFrame("Button", "$parentbtn" .. index, TestScrollFrame, "OptionsListButtonTemplate")
  42.     local button = TestScrollFrame.buttons[index]
  43.     button:SetSize(500, 20)
  44.     button:SetPoint("TOPLEFT", 8, -(index - 1) * 20 - 8)
  45.     button:SetScript(
  46.         "OnClick",
  47.         function(self, button)
  48.             if button == "RightButton" then
  49.                 print(TestData, self.index)
  50.                 updateScrollFrame()
  51.             end
  52.         end
  53.     )
  54. end

How do I solve the over-scrolling issue?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote