slider组件增加并发限制逻辑, 并移入表单组

master
yutent 2023-11-24 11:52:07 +08:00
parent a3f4b72ebd
commit 1f227a9d9d
2 changed files with 14 additions and 3 deletions

View File

@ -9,3 +9,4 @@ import './select.js'
import './star.js'
import './switch.js'
import './textarea.js'
import './slider.js'

View File

@ -38,8 +38,8 @@ class Slider extends Component {
}
},
vertical: false,
range: false,
disabled: false
disabled: false,
lazy: 'num!0'
}
#len = 100
@ -48,6 +48,8 @@ class Slider extends Component {
#value = 0 // 内部的值, 固定使用 0-100范围的值
#decimal = 0 //小数位
#stamp = 0
static styles = [
css`
:host {
@ -241,8 +243,9 @@ class Slider extends Component {
#seek(ev) {
let { clientWidth: w, clientHeight: h } = ev.target
let { min, max, step } = this
let { min, max, step, lazy } = this
let val = 0
let now = Date.now()
if (this.vertical) {
val = (h - ev.y) / h
@ -253,7 +256,14 @@ class Slider extends Component {
val += min
this.value = this.#fix(val)
// 并发拦截
if (lazy > 0 && now - this.#stamp < lazy) {
return
}
this.#stamp = now
this.$emit('input')
this.$emit('change')
}
#mousedown(ev) {