Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
aab2a2d3
U
uni-app
项目概览
MuGuiLin
/
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,发现更多精彩内容 >>
提交
aab2a2d3
编写于
3月 30, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 解决 canvas 组件上 touch 事件无法返回 x、y 属性的问题
上级
c5073791
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
8 deletion
+37
-8
src/core/view/components/canvas/index.vue
src/core/view/components/canvas/index.vue
+34
-6
src/core/view/plugins/events.js
src/core/view/plugins/events.js
+3
-2
未找到文件。
src/core/view/components/canvas/index.vue
浏览文件 @
aab2a2d3
...
...
@@ -2,9 +2,7 @@
<uni-canvas
:canvas-id=
"canvasId"
:disable-scroll=
"disableScroll"
v-on=
"$listeners"
@
touchmove=
"_touchmove"
>
v-on=
"_listeners"
>
<canvas
ref=
"canvas"
width=
"300"
...
...
@@ -28,6 +26,17 @@ function resolveColor (color) {
return
'
rgba(
'
+
color
.
join
(
'
,
'
)
+
'
)
'
}
function
processTouches
(
target
,
touches
)
{
return
([]).
map
.
call
(
touches
,
(
touche
)
=>
{
var
boundingClientRect
=
target
.
getBoundingClientRect
()
return
{
identifier
:
touche
.
identifier
,
x
:
touche
.
clientX
-
boundingClientRect
.
x
,
y
:
touche
.
clientY
-
boundingClientRect
.
y
}
})
}
export
default
{
name
:
'
Canvas
'
,
mixins
:
[
subscriber
],
...
...
@@ -49,6 +58,27 @@ export default {
computed
:
{
id
()
{
return
this
.
canvasId
},
_listeners
()
{
var
$listeners
=
Object
.
assign
({},
this
.
$listeners
)
var
events
=
[
'
touchstart
'
,
'
touchmove
'
,
'
touchend
'
]
events
.
forEach
(
event
=>
{
var
existing
=
$listeners
[
event
]
var
eventHandler
=
[]
if
(
existing
)
{
eventHandler
.
push
((
$event
)
=>
{
this
.
$trigger
(
event
,
Object
.
assign
({},
$event
,
{
touches
:
processTouches
(
$event
.
currentTarget
,
$event
.
touches
),
changedTouches
:
processTouches
(
$event
.
currentTarget
,
$event
.
changedTouches
)
}))
})
}
if
(
this
.
disableScroll
&&
event
===
'
touchmove
'
)
{
eventHandler
.
push
(
this
.
_touchmove
)
}
$listeners
[
event
]
=
eventHandler
})
return
$listeners
}
},
created
()
{
...
...
@@ -79,9 +109,7 @@ export default {
}
},
_touchmove
(
event
)
{
if
(
this
.
disableScroll
)
{
event
.
preventDefault
()
}
event
.
preventDefault
()
},
actionsChanged
({
actions
,
...
...
src/core/view/plugins/events.js
浏览文件 @
aab2a2d3
...
...
@@ -82,8 +82,9 @@ export function processEvent (name, $event = {}, detail = {}, target = {}, curre
detail
:
detail
,
target
:
processTarget
(
target
,
detail
),
currentTarget
:
processTarget
(
currentTarget
),
touches
:
processTouches
(
$event
.
touches
),
changedTouches
:
processTouches
(
$event
.
changedTouches
),
// 只处理系统事件
touches
:
$event
instanceof
Event
?
processTouches
(
$event
.
touches
)
:
$event
.
touches
,
changedTouches
:
$event
instanceof
Event
?
processTouches
(
$event
.
changedTouches
)
:
$event
.
changedTouches
,
preventDefault
()
{
},
stopPropagation
()
{
}
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录