diff --git a/src/form/index.js b/src/form/index.js index 77f2e3e..acc2971 100644 --- a/src/form/index.js +++ b/src/form/index.js @@ -9,3 +9,4 @@ import './select.js' import './star.js' import './switch.js' import './textarea.js' +import './slider.js' diff --git a/src/slider/index.js b/src/form/slider.js similarity index 96% rename from src/slider/index.js rename to src/form/slider.js index 1d43a5c..4edca1c 100644 --- a/src/slider/index.js +++ b/src/form/slider.js @@ -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) {