From 9e4f010625f5029f4c4d6e7610eb185a2231f3dd Mon Sep 17 00:00:00 2001 From: Petr Grabovoy Date: Sun, 29 May 2016 00:28:21 +0300 Subject: [PATCH] Fix of resetting scroll position on resize --- ViragDevTool.lua | 27 +++++++++++++++++++-------- ViragDevTool.xml | 19 +++---------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/ViragDevTool.lua b/ViragDevTool.lua index e682f7f..109a213 100644 --- a/ViragDevTool.lua +++ b/ViragDevTool.lua @@ -1,3 +1,9 @@ +local ADDON_NAME, ViragDevTool = ... + + +local pairs, tostring, type, print, string, getmetatable, table,pcall = pairs, tostring, type, print, string, getmetatable, table, pcall +local HybridScrollFrame_CreateButtons, HybridScrollFrame_GetOffset, HybridScrollFrame_Update = HybridScrollFrame_CreateButtons, HybridScrollFrame_GetOffset, HybridScrollFrame_Update + local ViragDevToolLinkedList = { size = 0; first = nil, last = nil } function ViragDevToolLinkedList:GetInfoAtPosition(position) @@ -92,8 +98,7 @@ function ViragDevToolLinkedList:Clear() self.last = nil end -local pairs, tostring, type, print, string, getmetatable, table,pcall = pairs, tostring, type, print, string, getmetatable, table,pcall -local HybridScrollFrame_CreateButtons, HybridScrollFrame_GetOffset, HybridScrollFrame_Update = HybridScrollFrame_CreateButtons, HybridScrollFrame_GetOffset, HybridScrollFrame_Update + function ViragDevTool_ExpandCell(info) @@ -137,15 +142,12 @@ function ViragDevTool_ClearData() ViragDevToolLinkedList:Clear() ViragDevTool_ScrollBar_Update() end -local ViragDevToolScrollFrameSize = 0; + + function ViragDevTool_ScrollBar_Update() local scrollFrame = ViragDevToolScrollFrame - - if (scrollFrame:GetHeight() > ViragDevToolScrollFrameSize) then - ViragDevToolScrollFrameSize = scrollFrame:GetHeight() - HybridScrollFrame_CreateButtons(scrollFrame, "ViragDevToolEntryTemplate", 0, -2) - end + ViragDevTool_ScrollBar_AddChildren(scrollFrame) local buttons = scrollFrame.buttons; local offset = HybridScrollFrame_GetOffset(scrollFrame) @@ -169,6 +171,15 @@ function ViragDevTool_ScrollBar_Update() end +function ViragDevTool_ScrollBar_AddChildren(self) + if ViragDevTool.ScrollBarHeight == nil or self:GetHeight() > ViragDevTool.ScrollBarHeight then + ViragDevTool.ScrollBarHeight = self:GetHeight() + + local scrollBarValue = self.scrollBar:GetValue() + HybridScrollFrame_CreateButtons(self, "ViragDevToolEntryTemplate", 0, -2) + self.scrollBar:SetValue(scrollBarValue); + end +end function ViragDevTool_UpdateListItem(node, info, id) diff --git a/ViragDevTool.xml b/ViragDevTool.xml index 26d7131..75dfe33 100644 --- a/ViragDevTool.xml +++ b/ViragDevTool.xml @@ -100,16 +100,15 @@ self:RegisterForDrag("LeftButton"); + self.scrollFrame.update = ViragDevTool_ScrollBar_Update + ViragDevTool_ScrollBar_Update() self:StartSizing() - - ViragDevTool_ScrollBar_Update() - - ViragDevTool_ScrollBar_Update() self:StopMovingOrSizing(); + ViragDevTool_ScrollBar_Update() - - - ViragDevTool_ScrollBar_Update() - - - - self.update = ViragDevTool_ScrollBar_Update - - @@ -168,9 +158,6 @@ self:GetParent():StartMoving() - - ViragDevTool_ScrollBar_Update() - self:GetParent():StopMovingOrSizing(); -- 1.7.9.5