better naming

This commit is contained in:
Bruno Windels 2019-01-28 16:30:34 +01:00
parent d833174d68
commit b0bb4eb5ab

View file

@ -207,8 +207,8 @@ export class Layout {
} }
// @param offset the amount the sectionIndex is moved from what is stored in _sectionHeights, positive if downwards // @param offset the amount the sectionIndex is moved from what is stored in _sectionHeights, positive if downwards
// if we're clamped, return the offset we should be clamped at. // if we're constrained, return the offset we should be constrained at.
_relayout(sectionIndex = 0, offset = 0, clamped = false) { _relayout(sectionIndex = 0, offset = 0, constrained = false) {
this._heights = this._sections.map((section) => this._sectionHeights[section.id]); this._heights = this._sections.map((section) => this._sectionHeights[section.id]);
// are these the amounts the items above/below shrank/grew and need to be relayouted? // are these the amounts the items above/below shrank/grew and need to be relayouted?
let overflowAbove; let overflowAbove;
@ -217,12 +217,12 @@ export class Layout {
const minHeight = this._getMinHeight(sectionIndex); const minHeight = this._getMinHeight(sectionIndex);
// new height > max ? // new height > max ?
if (this._heights[sectionIndex] + offset > maxHeight) { if (this._heights[sectionIndex] + offset > maxHeight) {
// we're pulling downwards and clamped // we're pulling downwards and constrained
// overflowAbove = minus how much are we above max height // overflowAbove = minus how much are we above max height
overflowAbove = (maxHeight - this._heights[sectionIndex]) - offset; overflowAbove = (maxHeight - this._heights[sectionIndex]) - offset;
overflowBelow = offset; overflowBelow = offset;
} else if (this._heights[sectionIndex] + offset < minHeight) { // new height < min? } else if (this._heights[sectionIndex] + offset < minHeight) { // new height < min?
// we're pulling upwards and clamped // we're pulling upwards and constrained
overflowAbove = (minHeight - this._heights[sectionIndex]) - offset; overflowAbove = (minHeight - this._heights[sectionIndex]) - offset;
overflowBelow = offset; overflowBelow = offset;
} else { } else {
@ -236,7 +236,7 @@ export class Layout {
overflowAbove = this._rebalanceAbove(sectionIndex, overflowAbove); overflowAbove = this._rebalanceAbove(sectionIndex, overflowAbove);
overflowBelow = this._rebalanceBelow(sectionIndex, overflowBelow); overflowBelow = this._rebalanceBelow(sectionIndex, overflowBelow);
if (!clamped) { // to avoid risk of infinite recursion if (!constrained) { // to avoid risk of infinite recursion
// clamp to avoid overflowing or underflowing the page // clamp to avoid overflowing or underflowing the page
if (Math.abs(overflowAbove) > 1.0) { if (Math.abs(overflowAbove) > 1.0) {
// here we do the layout again with offset - the amount of space we took too much // here we do the layout again with offset - the amount of space we took too much