Skip to content

Commit

Permalink
feat: 支持bototm和right,修复background-position在style解析不出负的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
heiazu committed Jun 27, 2024
1 parent 9f44666 commit d7f9818
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,20 @@ export function setNormalAttributeIntoInstance(instance: CommonAttribute, style:
}
if (style.position === 'absolute' || style.position === 'fixed') {
instance.position({
x: style.left || 0,
y: style.top || 0,
left: style.left,
top: style.top,
right: style.right,
bottom: style.bottom,
})
// 绝对定位和固定定位在web上都会脱离文档流,因此需要设置zIndex让它相比正常流的元素更上层
instance.zIndex(1)
}
if (style.position === 'relative') {
instance.offset({
x: style.left || 0,
y: style.top || 0,
left: style.left,
top: style.top,
right: style.right,
bottom: style.bottom,
})
// 绝对定位和固定定位在web上都会脱离文档流,因此需要设置zIndex让它相比正常流的元素更上层
instance.zIndex(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ function setBackgroundPosistion (hmStyle, value) {
} else if (horizontal === 'right' && vertical === 'bottom') {
hmStyle.backgroundPosition = Alignment.BottomEnd
} else {
if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
if (/^-?\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
hmStyle.backgroundPosition = { x: getUnit(horizontal) }
if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
if (/^-?\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
hmStyle.backgroundPosition = { x: getUnit(horizontal), y: getUnit(vertical) }
}
}
Expand Down

0 comments on commit d7f9818

Please sign in to comment.