Skip to content

Commit aae6026

Browse files
authored
Fixed: tab preview overlaps with other tabs (#16)
* fixed: tab preview overlaps with other tabs * Removed extra 4px from tab size
1 parent 377dd08 commit aae6026

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Plugins/DynamicPanels/Scripts/Panel.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ public void ValidateTabs()
9696
public int GetTabIndexAt( PointerEventData pointer, out Vector2 tabPreviewRect ) // x: position, y: size
9797
{
9898
int tabCount = panel.tabs.Count;
99+
float offset = panel.tabsParent.anchoredPosition.x;
99100
if( tabCount == 0 )
100101
{
101-
tabPreviewRect = new Vector2( 0f, panel.Size.x );
102+
tabPreviewRect = new Vector2( offset, panel.Size.x );
102103
return 0;
103104
}
104105

@@ -114,7 +115,7 @@ public int GetTabIndexAt( PointerEventData pointer, out Vector2 tabPreviewRect )
114115
if( i > 0 )
115116
i--;
116117

117-
tabPreviewRect = new Vector2( tabPosition, panel.tabs[i].Internal.RectTransform.sizeDelta.x + 4f );
118+
tabPreviewRect = new Vector2( offset + tabPosition, panel.tabs[i].Internal.RectTransform.sizeDelta.x );
118119
return i;
119120
}
120121

@@ -126,16 +127,16 @@ public int GetTabIndexAt( PointerEventData pointer, out Vector2 tabPreviewRect )
126127
{
127128
float remainingSize = panel.Size.x - tabPosition - tabSize;
128129
if( remainingSize < 30f )
129-
tabPreviewRect = new Vector2( tabPosition + tabSize * 0.5f, remainingSize + tabSize * 0.5f );
130+
tabPreviewRect = new Vector2( offset + tabPosition + tabSize * 0.5f, remainingSize + tabSize * 0.5f );
130131
else if( remainingSize > tabSize )
131-
tabPreviewRect = new Vector2( tabPosition + tabSize, tabSize );
132+
tabPreviewRect = new Vector2( offset + tabPosition + tabSize, tabSize );
132133
else
133-
tabPreviewRect = new Vector2( tabPosition + tabSize, remainingSize );
134+
tabPreviewRect = new Vector2( offset + tabPosition + tabSize, remainingSize );
134135

135136
return tabCount;
136137
}
137138

138-
tabPreviewRect = new Vector2( tabPosition, tabSize + 4f );
139+
tabPreviewRect = new Vector2( offset + tabPosition, tabSize );
139140
return tabCount - 1;
140141
}
141142

0 commit comments

Comments
 (0)