Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Redesign: new layout algorithm for room sublists. #2507

Merged
merged 15 commits into from
Jan 28, 2019

Conversation

bwindels
Copy link
Contributor

@bwindels bwindels requested a review from ara4n January 25, 2019 17:50
}

setHeight(height) {
this._layout._relayout(this._anchor, height - this._initialHeight);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, i'm surprised that you're throwing away the result of _relayout.

When dragging the handle, the prototype has:

        if (Math.sign(offset) != Math.sign(lastOffset)) clampedOffset = undefined;
        if (clampedOffset !== undefined) {
            if (offset < 0 && offset < clampedOffset) return;
            if (offset > 0 && offset > clampedOffset) return;
        }
        clampedOffset = layout(anchor, offset);
        if (clampedOffset !== undefined) {
            console.log(`layout is clamped to offset ${clampedOffset}`);
        }

This handles quite an important edge case where if you just keep recalculating the layout as the user resizes beyond the constraints of the layout, then you can find the layout suddenly popping into other solutions (typically, all the 'above' sections suddenly popping to be minHeight if you attempt to resize a given section to be massive). This is probably only true of the blend algorithm (which may be why you haven't seen it), and i concluded it was a feature of the alg rather than a bug.

So to mitigate it, you need to track whether the layout is already constrained (i.e. returns constrainedOffset != undefined) and is trying to push beyond the constraint, and if so abort the resize. This in turn needs an edge case so that if you change resize direction you mark the layout as not constrained, otherwise it can get stuck in constrained mode.

Given this probably isn't needed when in not-blended mode, it's not a disaster to skip implementing it - am including the explanation here for posterity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(n.b. i mentally s/clamped/constrained/g here to match https://github.com/matrix-org/matrix-react-sdk/pull/2507/files#r251215622)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, will do this (and the other feedback), but I got it in a usable state now and @lampholder suggested to get it in front of people ASAP so we know we're headed in the right direction for this. So propose to merge when the build succeeds, and have (immediate) follow-up PRs. Sgty?

@ara4n
Copy link
Member

ara4n commented Jan 26, 2019

this looks super promising to me - have made some minor comments to the WIP, but it's pretty much as i'd expect. thank you for grokking and porting the prototype over. can't wait to see if anyone else likes it! :)

@bwindels bwindels removed the notready label Jan 28, 2019
@bwindels bwindels merged commit 55e0838 into experimental Jan 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants