Skip to content

Commit

Permalink
WIP: stretchAndFix
Browse files Browse the repository at this point in the history
  • Loading branch information
ychetyrko committed Apr 14, 2024
1 parent b628843 commit 881f3b1
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions source/html/El.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,19 @@ export type ElCoords = {
}

export enum PosH {
left = 0,
center = 1,
right = 2,
stretch = 3,
left = 0,
center = 1,
right = 2,
stretch = 3,
stretchAndFix = 4,
}

export enum PosV {
top = 0,
center = 1,
bottom = 2,
stretch = 3,
top = 0,
center = 1,
bottom = 2,
stretch = 3,
stretchAndFix = 4,
}

export type Range = {
Expand Down Expand Up @@ -513,6 +515,7 @@ export class ElImpl<T extends Element = any, M = any> implements El<T, M> {
css.marginRight = "" // remove "auto"
break
case PosH.stretch:
case PosH.stretchAndFix:
css.justifySelf = "stretch"
if (oldPrimary === PosH.center) {
css.marginLeft = "" // remove "auto"
Expand All @@ -537,11 +540,12 @@ export class ElImpl<T extends Element = any, M = any> implements El<T, M> {
css.textAlign = "right"
break
case PosH.stretch:
case PosH.stretchAndFix:
css.alignItems = "stretch"
css.textAlign = "justify"
break
}
if (newPrimary === PosH.stretch && strength === undefined)
if (newPrimary >= PosH.stretch && strength === undefined)
ElImpl.applyStretchingStrengthH(element, 0, 1)
}

Expand Down Expand Up @@ -598,6 +602,7 @@ export class ElImpl<T extends Element = any, M = any> implements El<T, M> {
css.alignSelf = "end"
break
case PosV.stretch:
case PosV.stretchAndFix:
css.alignSelf = "stretch"
break
}
Expand All @@ -613,10 +618,11 @@ export class ElImpl<T extends Element = any, M = any> implements El<T, M> {
css.justifyContent = "end"
break
case PosV.stretch:
case PosV.stretchAndFix:
css.justifyContent = "stretch"
break
}
if (newPrimary === PosV.stretch && strength === undefined)
if (newPrimary >= PosV.stretch && strength === undefined)
ElImpl.applyStretchingStrengthV(element, 0, 1)
}

Expand Down

0 comments on commit 881f3b1

Please sign in to comment.