Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ChenYFan_OHHH
uni-app
提交
f66948e8
U
uni-app
项目概览
ChenYFan_OHHH
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f66948e8
编写于
10月 14, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复 picker-view 组件点击无法滚动的问题
上级
f325702d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
19 deletion
+32
-19
build/build.js
build/build.js
+2
-2
src/core/view/components/picker-view-column/index.vue
src/core/view/components/picker-view-column/index.vue
+29
-17
src/core/view/mixins/scroller/index.js
src/core/view/mixins/scroller/index.js
+1
-0
未找到文件。
build/build.js
浏览文件 @
f66948e8
...
@@ -32,7 +32,7 @@ service.run('build', {
...
@@ -32,7 +32,7 @@ service.run('build', {
formats
:
process
.
env
.
UNI_WATCH
===
'
true
'
?
'
umd
'
:
'
umd-min
'
,
formats
:
process
.
env
.
UNI_WATCH
===
'
true
'
?
'
umd
'
:
'
umd-min
'
,
entry
entry
}).
then
(
function
()
{
}).
then
(
function
()
{
if
(
process
.
env
.
UNI_UI
!==
'
true
'
)
{
if
(
process
.
env
.
UNI_
WATCH
!==
'
true
'
&&
process
.
env
.
UNI_
UI
!==
'
true
'
)
{
generateApiManifest
(
generateApiManifest
(
JSON
.
parse
(
JSON
.
stringify
(
process
.
UNI_SERVICE_API_MANIFEST
)),
JSON
.
parse
(
JSON
.
stringify
(
process
.
UNI_SERVICE_API_MANIFEST
)),
JSON
.
parse
(
JSON
.
stringify
(
process
.
UNI_SERVICE_API_PROTOCOL
))
JSON
.
parse
(
JSON
.
stringify
(
process
.
UNI_SERVICE_API_PROTOCOL
))
...
...
src/core/view/components/picker-view-column/index.vue
浏览文件 @
f66948e8
...
@@ -4,6 +4,24 @@ import scroller from 'uni-mixins/scroller/index'
...
@@ -4,6 +4,24 @@ import scroller from 'uni-mixins/scroller/index'
import
{
Friction
}
from
'
uni-mixins/scroller/Friction
'
import
{
Friction
}
from
'
uni-mixins/scroller/Friction
'
import
{
Spring
}
from
'
uni-mixins/scroller/Spring
'
import
{
Spring
}
from
'
uni-mixins/scroller/Spring
'
function
onClick
(
dom
,
callback
)
{
const
MAX_MOVE
=
20
const
hasTouchSupport
=
navigator
.
maxTouchPoints
let
x
=
0
let
y
=
0
dom
.
addEventListener
(
hasTouchSupport
?
'
touchstart
'
:
'
mousedown
'
,
(
event
)
=>
{
const
info
=
hasTouchSupport
?
event
.
changedTouches
[
0
]
:
event
x
=
info
.
clientX
y
=
info
.
clientY
})
dom
.
addEventListener
(
hasTouchSupport
?
'
touchend
'
:
'
mouseup
'
,
(
event
)
=>
{
const
info
=
hasTouchSupport
?
event
.
changedTouches
[
0
]
:
event
if
(
Math
.
abs
(
info
.
clientX
-
x
)
<
MAX_MOVE
&&
Math
.
abs
(
info
.
clientY
-
y
)
<
MAX_MOVE
)
{
callback
(
info
)
}
})
}
export
default
{
export
default
{
name
:
'
PickerViewColumn
'
,
name
:
'
PickerViewColumn
'
,
mixins
:
[
touchtrack
,
scroller
],
mixins
:
[
touchtrack
,
scroller
],
...
@@ -50,7 +68,6 @@ export default {
...
@@ -50,7 +68,6 @@ export default {
this
.
indicatorClass
=
$parent
.
indicatorClass
this
.
indicatorClass
=
$parent
.
indicatorClass
this
.
maskStyle
=
$parent
.
maskStyle
this
.
maskStyle
=
$parent
.
maskStyle
this
.
maskClass
=
$parent
.
maskClass
this
.
maskClass
=
$parent
.
maskClass
// this.__pageRerender = this._pageRerender.bind(this)
},
},
mounted
:
function
()
{
mounted
:
function
()
{
this
.
touchtrack
(
this
.
$refs
.
main
,
'
_handleTrack
'
,
true
)
this
.
touchtrack
(
this
.
$refs
.
main
,
'
_handleTrack
'
,
true
)
...
@@ -59,6 +76,7 @@ export default {
...
@@ -59,6 +76,7 @@ export default {
this
.
init
()
this
.
init
()
this
.
update
()
this
.
update
()
})
})
onClick
(
this
.
$el
,
this
.
_handleTap
.
bind
(
this
))
},
},
methods
:
{
methods
:
{
_setItemHeight
(
height
)
{
_setItemHeight
(
height
)
{
...
@@ -81,18 +99,17 @@ export default {
...
@@ -81,18 +99,17 @@ export default {
}
}
}
}
},
},
_handleTap
:
function
(
e
)
{
_handleTap
:
function
({
clientY
})
{
if
(
e
.
target
!==
e
.
currentTarget
&&
!
this
.
_scroller
.
isScrolling
())
{
if
(
!
this
.
_scroller
.
isScrolling
())
{
var
t
=
e
.
touches
&&
e
.
touches
[
0
]
&&
e
.
touches
[
0
].
clientY
var
rect
=
this
.
$el
.
getBoundingClientRect
()
var
n
=
typeof
t
===
'
number
'
?
t
:
e
.
detail
.
y
-
document
.
body
.
scrollTop
var
r
=
clientY
-
rect
.
top
-
this
.
height
/
2
var
i
=
this
.
$el
.
getBoundingClientRect
()
var
r
=
n
-
i
.
top
-
this
.
_height
/
2
var
o
=
this
.
indicatorHeight
/
2
var
o
=
this
.
indicatorHeight
/
2
if
(
!
(
Math
.
abs
(
r
)
<=
o
))
{
if
(
!
(
Math
.
abs
(
r
)
<=
o
))
{
var
a
=
Math
.
ceil
((
Math
.
abs
(
r
)
-
o
)
/
this
.
indicatorHeight
)
var
a
=
Math
.
ceil
((
Math
.
abs
(
r
)
-
o
)
/
this
.
indicatorHeight
)
var
s
=
r
<
0
?
-
a
:
a
var
s
=
r
<
0
?
-
a
:
a
this
.
current
+=
s
var
current
=
Math
.
min
(
this
.
current
+
s
,
this
.
length
-
1
)
this
.
_scroller
.
scrollTo
(
this
.
current
*
this
.
indicatorHeight
)
this
.
current
=
current
=
Math
.
max
(
current
,
0
)
this
.
_scroller
.
scrollTo
(
current
*
this
.
indicatorHeight
)
}
}
}
}
},
},
...
@@ -122,8 +139,8 @@ export default {
...
@@ -122,8 +139,8 @@ export default {
},
},
update
:
function
()
{
update
:
function
()
{
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
var
index
=
Math
.
max
(
this
.
length
-
1
,
0
)
var
current
=
Math
.
min
(
this
.
current
,
this
.
length
-
1
)
var
current
=
Math
.
min
(
this
.
current
,
index
)
current
=
Math
.
max
(
current
,
0
)
this
.
_scroller
.
update
(
current
*
this
.
indicatorHeight
,
undefined
,
this
.
indicatorHeight
)
this
.
_scroller
.
update
(
current
*
this
.
indicatorHeight
,
undefined
,
this
.
indicatorHeight
)
})
})
},
},
...
@@ -135,12 +152,7 @@ export default {
...
@@ -135,12 +152,7 @@ export default {
},
},
render
(
createElement
)
{
render
(
createElement
)
{
this
.
length
=
(
this
.
$slots
.
default
&&
this
.
$slots
.
default
.
length
)
||
0
this
.
length
=
(
this
.
$slots
.
default
&&
this
.
$slots
.
default
.
length
)
||
0
return
createElement
(
'
uni-picker-view-column
'
,
{
return
createElement
(
'
uni-picker-view-column
'
,
{},
[
on
:
{
tap
:
this
.
_handleTap
}
},
[
createElement
(
'
div
'
,
{
createElement
(
'
div
'
,
{
ref
:
'
main
'
,
ref
:
'
main
'
,
staticClass
:
'
uni-picker-view-group
'
staticClass
:
'
uni-picker-view-group
'
...
...
src/core/view/mixins/scroller/index.js
浏览文件 @
f66948e8
...
@@ -46,6 +46,7 @@ export default {
...
@@ -46,6 +46,7 @@ export default {
if
(
n
.
onTouchStart
)
{
if
(
n
.
onTouchStart
)
{
n
.
onTouchStart
()
n
.
onTouchStart
()
}
}
event
.
preventDefault
()
}
}
},
},
_handleTouchMove
:
function
(
event
)
{
_handleTouchMove
:
function
(
event
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录