在元素处于使用交互状态样式的时候修改样式
Closed this issue · 1 comments
Chocoer commented
当元素的 selected 状态为 true 时,它会应用 selectedStyle 的样式。但这时如果修改元素的 fill 和 selectedStyle,元素会变成 fill 设置的颜色,而不是使用 selectedStyle 中的 fill 样式。随后将 selected 修改为 false 后,元素的颜色变回了原本的 fill 颜色,而不是我新设置的 fill 颜色。
import { Leafer, Rect } from 'leafer-ui'
import '@leafer-in/state'
const leafer = new Leafer({ view: window })
const rect = new Rect({
width: 100,
height: 100,
fill: 'rgba(50,205,121, 0.7)',
cornerRadius: 30,
selectedStyle: {
fill: 'red'
}
})
leafer.add(rect)
setTimeout(() => {
rect.selected = true
setTimeout(() => {
rect.fill = "yellow";
rect.selectedStyle = {
fill: "blue"
};
}, 1000)
setTimeout(() => { rect.selected = false }, 2000)
}, 1000)
leaferjs commented
交互状态新版本有更新,到时会有样式覆盖的优先级说明