Merged PR 196: Implement Vertical orientation + Upgrade Heroicons to 2.0
Implémenter l'orientation verticale Modifier l'effet de append Implementer RigidBody Implementer Flex et simplex Implémenter Push Implémenter Swap Implement MinMaxHeight without behaviors Fix Margin for Height Implement PositionReference Fix dimension vertical position inside children Add orientation change in form Implement sortChildren Implement Anchor Fix warning message on overlapping Fix minimap when root container is vertical #7287 #7288 #7289 #7290 #7291 #7292 #7294 #7295 #7296 #7297 #7298 #7299 #7300 #7301 #7302
This commit is contained in:
parent
459e83a0c8
commit
18cbacaca1
45 changed files with 2112 additions and 1063 deletions
|
@ -1,4 +1,5 @@
|
|||
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
||||
import { Orientation } from '../../../Interfaces/Orientation';
|
||||
import { ReversePairwise } from '../../../utils/itertools';
|
||||
import { Flex } from './FlexBehaviors';
|
||||
|
||||
|
@ -7,17 +8,27 @@ import { Flex } from './FlexBehaviors';
|
|||
* @param container
|
||||
* @returns
|
||||
*/
|
||||
export function PushContainers(container: IContainerModel): IContainerModel {
|
||||
if (container.parent === null) {
|
||||
export function ApplyPush(container: IContainerModel, parent: IContainerModel): IContainerModel {
|
||||
if (parent.children.length <= 1) {
|
||||
return container;
|
||||
}
|
||||
|
||||
if (container.parent.children.length <= 1) {
|
||||
return container;
|
||||
const children = parent.children;
|
||||
const isHorizontal = parent.properties.orientation === Orientation.Horizontal;
|
||||
|
||||
if (isHorizontal) {
|
||||
PushContainersHorizontally(container, children);
|
||||
} else {
|
||||
PushContainersVertically(container, children);
|
||||
}
|
||||
|
||||
const prevIndex = container.parent.children.length - 2;
|
||||
const prev: IContainerModel = container.parent.children[prevIndex];
|
||||
Flex(container, parent);
|
||||
return container;
|
||||
}
|
||||
|
||||
export function PushContainersHorizontally(container: IContainerModel, children: IContainerModel[]): IContainerModel {
|
||||
const prevIndex = children.length - 2;
|
||||
const prev: IContainerModel = children[prevIndex];
|
||||
const isOverlapping = prev.properties.x + prev.properties.width > container.properties.x;
|
||||
if (!isOverlapping) {
|
||||
return container;
|
||||
|
@ -32,7 +43,7 @@ export function PushContainers(container: IContainerModel): IContainerModel {
|
|||
// FIXME: A fix was applied using toFixed(2).
|
||||
// FIXME: A coverture check must be done to ensure that all scenarios are covered
|
||||
|
||||
const it = ReversePairwise<IContainerModel>(container.parent.children.filter(child => child !== container));
|
||||
const it = ReversePairwise<IContainerModel>(children.filter(child => child !== container));
|
||||
|
||||
for (const { cur, next } of it) {
|
||||
const hasSpaceBetween = next.properties.x + next.properties.width < cur.properties.x;
|
||||
|
@ -48,9 +59,9 @@ export function PushContainers(container: IContainerModel): IContainerModel {
|
|||
break;
|
||||
}
|
||||
|
||||
const indexLastContainer = container.parent.children.indexOf(lastContainer);
|
||||
for (let i = indexLastContainer; i <= container.parent.children.length - 2; i++) {
|
||||
const sibling = container.parent.children[i];
|
||||
const indexLastContainer = children.indexOf(lastContainer);
|
||||
for (let i = indexLastContainer; i <= children.length - 2; i++) {
|
||||
const sibling = children[i];
|
||||
sibling.properties.x -= space;
|
||||
}
|
||||
}
|
||||
|
@ -58,16 +69,71 @@ export function PushContainers(container: IContainerModel): IContainerModel {
|
|||
const hasNoSpaceBetween = lastContainer === null;
|
||||
if (hasNoSpaceBetween) {
|
||||
// test gap between the left of the parent and the first container
|
||||
space = container.parent.children[0].properties.x;
|
||||
space = children[0].properties.x;
|
||||
if (space > 0) {
|
||||
for (let i = 0; i <= container.parent.children.length - 2; i++) {
|
||||
const sibling = container.parent.children[i];
|
||||
for (let i = 0; i <= children.length - 2; i++) {
|
||||
const sibling = children[i];
|
||||
sibling.properties.x -= space;
|
||||
}
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
Flex(container);
|
||||
return container;
|
||||
}
|
||||
|
||||
export function PushContainersVertically(container: IContainerModel, children: IContainerModel[]): IContainerModel {
|
||||
const prevIndex = children.length - 2;
|
||||
const prev: IContainerModel = children[prevIndex];
|
||||
const isOverlapping = prev.properties.y + prev.properties.height > container.properties.y;
|
||||
if (!isOverlapping) {
|
||||
return container;
|
||||
}
|
||||
|
||||
// find hole
|
||||
let lastContainer: IContainerModel | null = null;
|
||||
let space: number = 0;
|
||||
|
||||
while (space.toFixed(2) < container.properties.height.toFixed(2)) {
|
||||
// FIXME: possible infinite loop due to floating point
|
||||
// FIXME: A fix was applied using toFixed(2).
|
||||
// FIXME: A coverture check must be done to ensure that all scenarios are covered
|
||||
|
||||
const it = ReversePairwise<IContainerModel>(children.filter(child => child !== container));
|
||||
|
||||
for (const { cur, next } of it) {
|
||||
const hasSpaceBetween = next.properties.y + next.properties.height < cur.properties.y;
|
||||
if (hasSpaceBetween) {
|
||||
lastContainer = cur;
|
||||
space = cur.properties.y - (next.properties.y + next.properties.height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastContainer === null) {
|
||||
// no space between
|
||||
break;
|
||||
}
|
||||
|
||||
const indexLastContainer = children.indexOf(lastContainer);
|
||||
for (let i = indexLastContainer; i <= children.length - 2; i++) {
|
||||
const sibling = children[i];
|
||||
sibling.properties.y -= space;
|
||||
}
|
||||
}
|
||||
|
||||
const hasNoSpaceBetween = lastContainer === null;
|
||||
if (hasNoSpaceBetween) {
|
||||
// test gap between the left of the parent and the first container
|
||||
space = children[0].properties.y;
|
||||
if (space > 0) {
|
||||
for (let i = 0; i <= children.length - 2; i++) {
|
||||
const sibling = children[i];
|
||||
sibling.properties.y -= space;
|
||||
}
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue