Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lively.morphic/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export class TilingLayout extends Layout {
this._justifySubmorphs = props.justifySubmorphs || 'packed';
this._hugContentsVertically = props.hugContentsVertically || false;
this._hugContentsHorizontally = props.hugContentsHorizontally || false;
this._orderByIndex = props.orderByIndex || true;
this._orderByIndex = props.orderByIndex === false ? props.orderByIndex : true;
this._wrapSubmorphs = false;
if (typeof props.wrapSubmorphs !== 'undefined') {
this._wrapSubmorphs = props.wrapSubmorphs;
Expand Down Expand Up @@ -497,7 +497,7 @@ export class TilingLayout extends Layout {
if (config.hugContentsHorizontally !== false) spec.hugContentsHorizontally = true;
break;
case 'orderByIndex':
if (config.orderByIndex !== false && config.renderViaCSS === false) spec.orderByIndex = true;
if (!config.orderByIndex) spec.orderByIndex = config.orderByIndex;
break;
case 'wrapSubmorphs':
if (config.wrapSubmorphs !== false) spec.wrapSubmorphs = true;
Expand Down Expand Up @@ -539,7 +539,7 @@ export class TilingLayout extends Layout {
align,
axisAlign,
spacing,
orderByIndex: !renderViaCSS && orderByIndex,
orderByIndex,
reactToSubmorphAnimations,
renderViaCSS,
padding,
Expand Down Expand Up @@ -572,7 +572,7 @@ export class TilingLayout extends Layout {
* Warning: This property is not supported when the layout is rendered via CSS and defaults to true in this case.
* @type {Boolean}
*/
get orderByIndex () { return this._orderByIndex || this.renderViaCSS; }
get orderByIndex () { return this._orderByIndex; }
set orderByIndex (active) { this._orderByIndex = active; this.onConfigUpdate(); }

/**
Expand Down Expand Up @@ -986,7 +986,7 @@ export class TilingLayout extends Layout {
}
style.top = 'unset';
style.left = 'unset';
style.order = layoutableSubmorphs.indexOf(morph); // already handled by the node ordering
style.order = this.orderByIndex ? layoutableSubmorphs.indexOf(morph) : layoutableSubmorphs.length - 1 - layoutableSubmorphs.indexOf(morph); // already handled by the node ordering
const hasNextSibling = layoutableSubmorphs.length > style.order + 1;
const hasPrevSibling = style.order > 0;

Expand Down Expand Up @@ -1224,6 +1224,7 @@ export class TilingLayout extends Layout {
if (resetNodes) {
while (containerNode.getChildCount()) containerNode.removeChild(containerNode.getChild(0));
i = 0;
if (!this.orderByIndex) layoutableSubmorphs = layoutableSubmorphs.reverse();
for (let m of layoutableSubmorphs) {
let subNode = this.ensureYogaNodeFor(m); let danglingParent;
if (danglingParent = subNode.getParent()) danglingParent.removeChild(subNode);
Expand Down Expand Up @@ -1433,8 +1434,7 @@ export class TilingLayout extends Layout {
layoutOrder (morph) {
// the following creates a drop zone that is 15 pixels tall.
// allows for horizontal reordering.
if (this.orderByIndex) return this.container.getProperty('submorphs').indexOf(morph);
return this.axis === 'row' ? (morph.top - morph.top % 15) * 1000000 + morph.left : (morph.left - morph.left % 15) * 1000000 + morph.top;
return this.container.getProperty('submorphs').indexOf(morph);
}
}

Expand Down