resolveBackgroundPosition static method
CSSBackgroundPosition
resolveBackgroundPosition(
- String input,
- RenderStyle renderStyle,
- String propertyName,
- bool isHorizontal,
Parse background-position-x/background-position-y from string to CSSBackgroundPosition type.
Implementation
static CSSBackgroundPosition resolveBackgroundPosition(String input, RenderStyle renderStyle, String propertyName, bool isHorizontal) {
if (CSSPercentage.isPercentage(input)) {
return CSSBackgroundPosition(percentage: _gatValuePercentage(input));
} else if (CSSLength.isLength(input)) {
return CSSBackgroundPosition(length: CSSLength.parseLength(input, renderStyle, propertyName));
} else {
if (isHorizontal) {
switch (input) {
case LEFT:
return CSSBackgroundPosition(percentage: -1);
case RIGHT:
return CSSBackgroundPosition(percentage: 1);
case CENTER:
return CSSBackgroundPosition(percentage: 0);
default:
return CSSBackgroundPosition(percentage: -1);
}
} else {
switch (input) {
case TOP:
return CSSBackgroundPosition(percentage: -1);
case BOTTOM:
return CSSBackgroundPosition(percentage: 1);
case CENTER:
return CSSBackgroundPosition(percentage: 0);
default:
return CSSBackgroundPosition(percentage: -1);
}
}
}
}