Skip to content

Commit 7303e9a

Browse files
authored
fix: select scorll in mobile (#3707)
1 parent 006e23a commit 7303e9a

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

components/vc-virtual-list/hooks/useMobileTouchMove.ts

+29-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import supportsPassive from '../../_util/supportsPassive';
2-
import { watch, Ref } from 'vue';
2+
import { watch, Ref, onMounted } from 'vue';
33

44
const SMOOTH_PTG = 14 / 15;
55

@@ -80,28 +80,34 @@ export default function useMobileTouchMove(
8080
}
8181
};
8282

83-
watch(inVirtual, val => {
84-
listRef.value.removeEventListener(
85-
'touchstart',
86-
onTouchStart,
87-
supportsPassive
88-
? ({
89-
passive: false,
90-
} as EventListenerOptions)
91-
: false,
83+
onMounted(() => {
84+
watch(
85+
inVirtual,
86+
val => {
87+
listRef.value.removeEventListener(
88+
'touchstart',
89+
onTouchStart,
90+
supportsPassive
91+
? ({
92+
passive: false,
93+
} as EventListenerOptions)
94+
: false,
95+
);
96+
cleanUpEvents();
97+
clearInterval(interval);
98+
if (val) {
99+
listRef.value.addEventListener(
100+
'touchstart',
101+
onTouchStart,
102+
supportsPassive
103+
? ({
104+
passive: false,
105+
} as EventListenerOptions)
106+
: false,
107+
);
108+
}
109+
},
110+
{ immediate: true },
92111
);
93-
cleanUpEvents();
94-
clearInterval(interval);
95-
if (val) {
96-
listRef.value.addEventListener(
97-
'touchstart',
98-
onTouchStart,
99-
supportsPassive
100-
? ({
101-
passive: false,
102-
} as EventListenerOptions)
103-
: false,
104-
);
105-
}
106112
});
107113
}

0 commit comments

Comments
 (0)