HeightSizable¶
Overview¶
HeightSizable is a trait that provides a minimum and preferred height. The minimum height is set by the component, so that layout containers could know how "small" the component can be made. The preferred height is set by the layout container, and the component should adjust its size so that it takes up that height.
@author Jonathan Olson <jonathan.olson@colorado.edu>
Type HeightSizableNode¶
Some typescript gymnastics to provide a user-defined type guard that treats something as HeightSizable. We need to define an unused function with a concrete type, so that we can extract the return type of the function and provide a type for a Node that extends this type.
Type HeightSizableOptions¶
- preferredHeight?: number | null
Sets the preferred height of the Node in the parent coordinate frame. Nodes that implement this will attempt to keep theirnode.height
at this value. If null, the node will likely set its configuration to the minimum height. NOTE: changing this or localPreferredHeight will adjust the other. NOTE: preferredHeight is not guaranteed currently. The component may end up having a smaller or larger size - minimumHeight?: number | null
Sets the minimum height of the Node in the parent coordinate frame. Usually not directly set by a client. Usually a resizable Node will set its localMinimumHeight (and that will get transferred to this value in the parent coordinate frame). NOTE: changing this or localMinimumHeight will adjust the other. NOTE: when the Node's transform is updated, this value is recomputed based on localMinimumHeight - localPreferredHeight?: number | null
Sets the preferred height of the Node in the local coordinate frame. NOTE: changing this or preferredHeight will adjust the other. NOTE: when the Node's transform is updated, this value is recomputed based on preferredHeight NOTE: localPreferredHeight is not guaranteed currently. The component may end up having a smaller or larger size - localMinimumHeight?: number | null
Sets the minimum height of the Node in the local coordinate frame. Usually set by the resizable Node itself to indicate what preferred sizes are possible. NOTE: changing this or minimumHeight will adjust the other. - heightSizable?: boolean
Whether this component will have its preferred size set by things like layout containers. If this is set to false, it's recommended to set some sort of preferred size (so that it won't go to 0)
Type THeightSizable¶
- preferredHeightProperty: TinyProperty<number | null>
- minimumHeightProperty: TinyProperty<number | null>
- localPreferredHeightProperty: TinyProperty<number | null>
- localMinimumHeightProperty: TinyProperty<number | null>
- isHeightResizableProperty: TinyProperty<boolean>
- preferredHeight: number | null
- localPreferredHeight: number | null
- minimumHeight: number | null
- localMinimumHeight: number | null
- heightSizable: boolean
- _preferredSizeChanging: boolean
@mixin-protected - made public for use in the mixin only - _minimumSizeChanging: boolean
- _preferredSizeChangeAttemptDuringLock: boolean
- _minimumSizeChangeAttemptDuringLock: boolean
- _updatePreferredHeightListener: () => void
- _updateLocalPreferredHeightListener: () => void
- _updateMinimumHeightListener: () => void
- _updateLocalMinimumHeightListener: () => void
Source Code¶
See the source for HeightSizable.ts in the scenery repository.