diff --git a/example/docs/zh-CN/components/slider.md b/example/docs/zh-CN/components/slider.md index 29310cc7..9dfcd472 100644 --- a/example/docs/zh-CN/components/slider.md +++ b/example/docs/zh-CN/components/slider.md @@ -1,7 +1,7 @@ ::: demo \ No newline at end of file +const standardMove = (e: MouseEvent) => { + if (!standardtracker.value) { + return; + } + let tracker_rect = standardtracker.value.getBoundingClientRect(); + let origin_left = tracker_rect.left; + let point_left = e.clientX; + let distance = point_left - origin_left; + if (distance < 0) { + standard_style.left = 0; + standard_style.width = 0; + } else { + let rate = (distance / tracker_rect.width) * 100; + standard_style.left = Math.floor(rate); + standard_style.width = Math.floor(rate); + if (standard_style.left > 100) { + standard_style.left = 100; + standard_style.width = 100; + // props.modelValue = 100; + } + } + emit("update:modelValue", standard_style.left); +}; +const verticalMove = (e: MouseEvent) => { + if (!verticaltracker.value) { + return; + } + let tracker_rect = verticaltracker.value.getBoundingClientRect(); + let origin_bottom = tracker_rect.bottom; + let point_bottom = e.clientY; + let distance = (point_bottom - origin_bottom) * -1 + if (distance < 0) { + vertical_style.bottom = 0; + vertical_style.height = 0; + } else { + let rate = (distance / tracker_rect.height) * 100; + console.log(rate) + vertical_style.bottom = Math.floor(rate); + vertical_style.height = Math.floor(rate); + if (vertical_style.bottom > 100) { + vertical_style.bottom = 100; + vertical_style.height = 100; + // props.modelValue = 100; + } + } + emit("update:modelValue", vertical_style.bottom); +}; +