提交 74096b2b 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

fix: 优化 touch mouse 事件同时绑定及navigator a 标签阻止默认事件

上级 adb326c3
...@@ -45,16 +45,19 @@ export function useHover(props: UseHoverOptions) { ...@@ -45,16 +45,19 @@ export function useHover(props: UseHoverOptions) {
if (evt.touches.length > 1) { if (evt.touches.length > 1) {
return return
} }
handleHover(evt) handleHoverStart(evt)
} }
function onMousedown(evt: MouseEvent) { function onMousedown(evt: MouseEvent) {
evt.preventDefault() if (hoverTouch) {
handleHover(evt) return
}
handleHoverStart(evt)
window.addEventListener('mouseup', handlePCHoverEnd) window.addEventListener('mouseup', handlePCHoverEnd)
} }
function handleHover(evt: TouchEvent | MouseEvent) { function handleHoverStart(evt: TouchEvent | MouseEvent) {
// TODO detect scrolling // TODO detect scrolling
if ((evt as any)._hoverPropagationStopped) { if ((evt as any)._hoverPropagationStopped) {
return return
...@@ -80,6 +83,10 @@ export function useHover(props: UseHoverOptions) { ...@@ -80,6 +83,10 @@ export function useHover(props: UseHoverOptions) {
} }
function onMouseup() { function onMouseup() {
if (!hoverTouch) {
return
}
handlePCHoverEnd() handlePCHoverEnd()
} }
......
...@@ -27,7 +27,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -27,7 +27,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({
const hasHoverClass = props.hoverClass && props.hoverClass !== 'none' const hasHoverClass = props.hoverClass && props.hoverClass !== 'none'
return ( return (
<a class="navigator-wrap" href={url} onClick={onEventPrevent}> <a
class="navigator-wrap"
href={url}
onClick={onEventPrevent}
onMousedown={onEventPrevent}
>
<uni-navigator <uni-navigator
class={hasHoverClass && hovering.value ? hoverClass : ''} class={hasHoverClass && hovering.value ? hoverClass : ''}
{...(hasHoverClass && binding)} {...(hasHoverClass && binding)}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册