Skip to content

Commit

Permalink
fix for #633
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Sep 23, 2024
1 parent 22636f2 commit dcb9c92
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions haxe/ui/core/Component.hx
Original file line number Diff line number Diff line change
Expand Up @@ -660,31 +660,29 @@ class Component extends ComponentImpl
}

private function assignPositionClasses(invalidate:Bool = true) {
if (childComponents.length == 1) {
childComponents[0].addClasses(["first", "last"], invalidate);
return;
}
var effectiveChildCount = 0;
for (i in 0...childComponents.length) {
var c = childComponents[i];
if (!c.includeInLayout) {
var effectiveChildren = [];
for (c in childComponents) {
if (!c.includeInLayout || c.hidden) {
continue;
}
effectiveChildCount++;
effectiveChildren.push(c);
}

if (effectiveChildren.length == 1) {
effectiveChildren[0].addClasses(["first", "last"], invalidate);
return;
}

var n = 0;
for (i in 0...childComponents.length) {
var c = childComponents[i];
if (!c.includeInLayout) {
continue;
}
if (i == 0) {
for (c in effectiveChildren) {
if (n == 0) {
c.swapClass("first", "last", invalidate);
} else if (i == effectiveChildCount - 1) {
} else if (n == effectiveChildren.length - 1) {
c.swapClass("last", "first", invalidate);
} else {
c.removeClasses(["first", "last"], invalidate);
}

n++;
}
}
Expand Down

0 comments on commit dcb9c92

Please sign in to comment.