Skip to content

Commit 816ef20

Browse files
committed
feat: disabled slider
1 parent c7e4e8c commit 816ef20

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

example/pages/slider/index-ios.mpx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
backgroundColor="{{ '#cccccc' }}"
1010
activeColor="{{ '#FF6430' }}"
1111
block-size="{{ 28 }}"
12+
disabled="{{false}}"
1213
show-value="{{true}}"
1314
custom-content="{{true}}"
1415
bindchange="handleChange"

packages/mpx-cube-ui/src/components/slider/slider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ createComponent({
218218
}
219219
},
220220
async onClick(e) {
221+
if (this.disabled) return
221222
const rect = await this.getRect()
222223
this.startDragRect = rect
223224
this.calcProgress(e.detail.x, rect)
@@ -226,13 +227,14 @@ createComponent({
226227
this.triggerEvent(EVENT_CHANGE, { value: this.currentValue })
227228
},
228229
async startHandler(e) {
230+
if (this.disabled) return
229231
if (__mpx_mode__ === 'web') {
230232
e && e.preventDefault()
231233
}
232234
this.startDragRect = await this.getRect()
233235
},
234236
moveHandler(e) {
235-
if (!this.startDragRect) {
237+
if (this.disabled || !this.startDragRect) {
236238
return
237239
}
238240
const x = e.touches[0].clientX
@@ -245,6 +247,7 @@ createComponent({
245247
}
246248
},
247249
endHandler() {
250+
if (this.disabled) return
248251
this.startDragRect = null
249252
// 完成一次拖动后触发的事件
250253
// @arg event.detail = {value}

0 commit comments

Comments
 (0)