You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.2 KiB
98 lines
2.2 KiB
|
|
const SidingRefDimensions = Object.freeze({
|
|
WIDTH: (DirectionUnitDependentAttribute) => DirectionUnitDependentAttribute._fFirst,
|
|
HEIGHT: (DirectionUnitDependentAttribute) => DirectionUnitDependentAttribute._fSecond
|
|
})
|
|
|
|
/**
|
|
* Simple Dimensions container for the height and width in pixels.
|
|
*/
|
|
class Dimensions extends DirectionUnitDependentAttribute {
|
|
constructor(defaultValue = 0, defaultUnit = SizeUnits.PIXEL) {
|
|
super();
|
|
this._unit = defaultUnit;
|
|
this._fFirst = defaultValue;
|
|
this._fSecond = defaultValue;
|
|
}
|
|
|
|
/**
|
|
* Sets width (x) value of amount
|
|
* @param {number} amount
|
|
* @returns {Dimensions} this Dimensions Modifier
|
|
*/
|
|
width(amount) {
|
|
this._fFirst = amount;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Sets height (y) value of amount
|
|
* @param {number} amount
|
|
* @returns {Dimensions} this Dimensions Modifier
|
|
*/
|
|
height(amount) {
|
|
this._fSecond = amount;
|
|
return this;
|
|
}
|
|
|
|
|
|
getOrderedValues() {
|
|
return this.getOrderedValues().slice(2)
|
|
}
|
|
|
|
getSidingRefValueMap() {
|
|
return {
|
|
[SidingRefDimensions.WIDTH]: this.getBySidingRef(SidingRefDimensions.WIDTH),
|
|
[SidingRefDimensions.HEIGHT]: this.getBySidingRef(SidingRefDimensions.HEIGHT)
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
class DimensionsChain extends Dimensions {
|
|
_modifier;
|
|
constructor(modifier) {
|
|
super();
|
|
this._modifier = modifier;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @returns {Modifier|ChainableModifier}
|
|
*/
|
|
toModifier() {
|
|
return this._modifier
|
|
.dimensions(this);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @returns {Modifier|ChainableModifier}
|
|
*/
|
|
ensureModifier() {
|
|
return this.toModifier()
|
|
}
|
|
}
|
|
|
|
class ChainableDimensions extends DimensionsChain {
|
|
toComponent() {
|
|
return this._modifier
|
|
.dimensions(this)
|
|
.toComponent();
|
|
}
|
|
|
|
componentChild(innerComponent) {
|
|
return this._modifier
|
|
.dimensions(this)
|
|
.toComponent()
|
|
.componentChild(innerComponent);
|
|
}
|
|
|
|
componentChildren(innerComponent) {
|
|
return this._modifier
|
|
.dimensions(this)
|
|
.toComponent()
|
|
.componentChildren(innerComponent);
|
|
}
|
|
}
|
|
|
|
|