fix: slider - 修复step参数 & 优化拖动逻辑
This commit is contained in:
parent
22e88e458e
commit
03aac6076a
@ -19,8 +19,11 @@ const props = withDefaults(defineProps<Prop>(), {
|
||||
let rv = toRef(props, "rangeValue");
|
||||
|
||||
const moveAction = throttle(rangeMove);
|
||||
let currbtn = -1;
|
||||
|
||||
function handle_mousedown() {
|
||||
currbtn = -1;
|
||||
tooptipHide.value = false;
|
||||
on("selectstart", window, handle_select, { once: true });
|
||||
on("mouseup", window, handle_mouseup);
|
||||
on("mousemove", window, moveAction);
|
||||
@ -31,7 +34,6 @@ function handle_mouseup() {
|
||||
off("selectstart", document, handle_select);
|
||||
off("mouseup", window, handle_mouseup);
|
||||
off("mousemove", window, moveAction);
|
||||
currbtn = -1;
|
||||
}
|
||||
function handle_select(e: Event): void {
|
||||
e.preventDefault();
|
||||
@ -39,11 +41,11 @@ function handle_select(e: Event): void {
|
||||
|
||||
const tracker = ref<HTMLElement | null>(null);
|
||||
const emit = defineEmits(["link-val-hook"]);
|
||||
let currbtn = -1;
|
||||
|
||||
const tooptipHide = ref<Boolean>(true);
|
||||
|
||||
function rangeMove(e: MouseEvent) {
|
||||
tooptipHide.value = false;
|
||||
// tooptipHide.value = false;
|
||||
if (!tracker.value) {
|
||||
return;
|
||||
}
|
||||
|
@ -20,8 +20,10 @@ const props = withDefaults(defineProps<Prop>(), {
|
||||
let rv = toRef(props, "rangeValue");
|
||||
|
||||
const moveAction = throttle(rangeMove);
|
||||
|
||||
let currbtn = -1;
|
||||
function handle_mousedown() {
|
||||
currbtn = -1;
|
||||
tooptipHide.value = false;
|
||||
on("selectstart", window, handle_select, { once: true });
|
||||
on("mouseup", window, handle_mouseup);
|
||||
on("mousemove", window, moveAction);
|
||||
@ -32,7 +34,6 @@ function handle_mouseup() {
|
||||
off("selectstart", document, handle_select);
|
||||
off("mouseup", window, handle_mouseup);
|
||||
off("mousemove", window, moveAction);
|
||||
currbtn = -1;
|
||||
}
|
||||
function handle_select(e: Event): void {
|
||||
e.preventDefault();
|
||||
@ -40,11 +41,11 @@ function handle_select(e: Event): void {
|
||||
|
||||
const tracker = ref<HTMLElement | null>(null);
|
||||
const emit = defineEmits(["link-val-hook"]);
|
||||
let currbtn = -1;
|
||||
|
||||
const tooptipHide = ref<Boolean>(true);
|
||||
|
||||
function rangeMove(e: MouseEvent) {
|
||||
tooptipHide.value = false;
|
||||
// tooptipHide.value = false;
|
||||
if (!tracker.value) {
|
||||
return;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ function valHook(val: any) {
|
||||
<div v-if="range">
|
||||
<!-- 纵向区间 -->
|
||||
<VerticalRange
|
||||
:step="10"
|
||||
:step="step"
|
||||
@linkValHook="valHook"
|
||||
:disabled="disabled"
|
||||
:rangeValue="rangeValues"
|
||||
@ -65,7 +65,7 @@ function valHook(val: any) {
|
||||
<div v-if="range">
|
||||
<!-- 横向区间 -->
|
||||
<StandardRange
|
||||
:step="10"
|
||||
:step="step"
|
||||
@linkValHook="valHook"
|
||||
:disabled="disabled"
|
||||
:rangeValue="rangeValues"
|
||||
|
@ -5,7 +5,7 @@ export function throttle(func: Function) {
|
||||
timer = setTimeout(() => {
|
||||
timer = null;
|
||||
func(args);
|
||||
}, 20);
|
||||
}, 30);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user