TASK: #111576 列slider cover 属性支持小数

This commit is contained in:
duanzhijiang 2022-09-28 14:40:49 +08:00
parent 500951aa8e
commit 69958f7db8
2 changed files with 6 additions and 4 deletions

View File

@ -14,8 +14,10 @@
```
2. `cover` --- 初始填充<br>
`cover="50"``cover="50%"`都表示初始填充音量条的50%<br>
`cover="150px"` 表示准确的填充长度<br>
`cover="50"``cover="50%"` 都表示初始填充音量条的50%<br>
`cover="78.2"``cover="78.2%"` 都表示初始填充音量条的78.2%<br>
`cover="150px"``cover="113.5px"` 表示准确的填充长度<br>
```
<star-slider cover="150px"></star-slider>

View File

@ -3,9 +3,9 @@ import {customElement, property, query} from 'lit/decorators.js'
import {sharedStyles} from './slider-styles.js'
function getType(str: string) {
if (/^\d*px$/.test(str)) {
if (/^\d*(\.\d*)?px$/.test(str)) {
return 'static'
} else if (/^\d*%?$/.test(str)) {
} else if (/^\d*(\.\d*)?%?$/.test(str)) {
return 'percent'
} else {
return 'invalid'