提交 41823711 编写于 作者: Q qiang

fix: 优化 uni-picker-view-column 组件鼠标操作效果

上级 8b518291
...@@ -13,16 +13,15 @@ import { ...@@ -13,16 +13,15 @@ import {
function initClick (dom) { function initClick (dom) {
const MAX_MOVE = 20 const MAX_MOVE = 20
const hasTouchSupport = navigator.maxTouchPoints
let x = 0 let x = 0
let y = 0 let y = 0
dom.addEventListener(hasTouchSupport ? 'touchstart' : 'mousedown', (event) => { dom.addEventListener('touchstart', (event) => {
const info = hasTouchSupport ? event.changedTouches[0] : event const info = event.changedTouches[0]
x = info.clientX x = info.clientX
y = info.clientY y = info.clientY
}) })
dom.addEventListener(hasTouchSupport ? 'touchend' : 'mouseup', (event) => { dom.addEventListener('touchend', (event) => {
const info = hasTouchSupport ? event.changedTouches[0] : event const info = event.changedTouches[0]
if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) { if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
let customEvent = new CustomEvent('click', { let customEvent = new CustomEvent('click', {
bubbles: true, bubbles: true,
...@@ -301,6 +300,7 @@ export default { ...@@ -301,6 +300,7 @@ export default {
width: 100%; width: 100%;
will-change: transform; will-change: transform;
padding: 102px 0; padding: 102px 0;
cursor: pointer;
} }
.uni-picker-view-content>* { .uni-picker-view-content>* {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册