(chore)format code.

This commit is contained in:
wangchangqi 2022-09-29 16:25:58 +08:00
parent d5a936c779
commit b3631c7965
3 changed files with 19 additions and 14 deletions

View File

@ -112,21 +112,27 @@ export class StarClock extends LitElement {
} }
} }
protected dateUpdated(date: any) { protected dateUpdated(date: any) {
let myDate = date.split(':') //将字符串拆分为数组 let myDate = date.split(':') //将字符串拆分为数组
let secondTime = Number(myDate[2] || 0) //获取秒针时间 let secondTime = Number(myDate[2] || 0) //获取秒针时间
let minuteTime = Number(myDate[1] || 0) + secondTime / 60 //获取分针时间 let minuteTime = Number(myDate[1] || 0) + secondTime / 60 //获取分针时间
let hourTime = Number(myDate[0] || 0) + minuteTime / 60 //获取时针时间 let hourTime = Number(myDate[0] || 0) + minuteTime / 60 //获取时针时间
hourTime >= 12 ? (hourTime -= 12) : '' //24小时转换为12小时 hourTime >= 12 ? (hourTime -= 12) : '' //24小时转换为12小时
this.rotateSecond = (secondTime / 60) * 360 //秒针旋转角度 this.rotateSecond = (secondTime / 60) * 360 //秒针旋转角度
this.rotateMinute = (minuteTime / 60) * 360 //分针旋转角度 this.rotateMinute = (minuteTime / 60) * 360 //分针旋转角度
this.rotateHour = (hourTime / 12) * 360 //时针旋转角度 this.rotateHour = (hourTime / 12) * 360 //时针旋转角度
} }
protected firstUpdated() { protected firstUpdated() {
this.style.setProperty('--rotateSecond', this.rotateSecond + 'deg') this.style.setProperty('--rotateSecond', this.rotateSecond + 'deg')
this.style.setProperty('--rotateMinute', this.rotateMinute + 'deg') this.style.setProperty('--rotateMinute', this.rotateMinute + 'deg')
this.style.setProperty('--rotateHour', this.rotateHour + 'deg') this.style.setProperty('--rotateHour', this.rotateHour + 'deg')
this.style.setProperty('--rotateSecondAfter',this.rotateSecond + 360 + 'deg') this.style.setProperty(
this.style.setProperty('--rotateMinuteAfter',this.rotateMinute + 360 + 'deg') '--rotateSecondAfter',
this.rotateSecond + 360 + 'deg'
)
this.style.setProperty(
'--rotateMinuteAfter',
this.rotateMinute + 360 + 'deg'
)
this.style.setProperty('--rotateHourAfter', this.rotateHour + 360 + 'deg') this.style.setProperty('--rotateHourAfter', this.rotateHour + 360 + 'deg')
let min = Math.min( let min = Math.min(

View File

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

View File

@ -10,4 +10,4 @@
圆点+横条,由 svg 组成。 圆点+横条,由 svg 组成。
TODO: 添加可形变动画。 TODO: 添加可形变动画。