Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
878a3868
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
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,发现更多精彩内容 >>
提交
878a3868
编写于
1月 20, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): pageY and clientY
上级
0141ff60
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
16 deletion
+23
-16
packages/uni-core/src/helpers/dom.ts
packages/uni-core/src/helpers/dom.ts
+8
-4
packages/uni-core/src/view/plugin/componentInstance.ts
packages/uni-core/src/view/plugin/componentInstance.ts
+4
-4
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+11
-8
未找到文件。
packages/uni-core/src/helpers/dom.ts
浏览文件 @
878a3868
...
...
@@ -4,18 +4,22 @@ import safeAreaInsets from 'safe-area-insets'
export
const
onEventPrevent
=
/*#__PURE__*/
withModifiers
(()
=>
{},
[
'
prevent
'
])
export
const
onEventStop
=
/*#__PURE__*/
withModifiers
(()
=>
{},
[
'
stop
'
])
function
getWindowOffsetCssVar
(
style
:
CSSStyleDeclaration
,
name
:
string
)
{
return
parseInt
((
style
.
getPropertyValue
(
name
).
match
(
/
\d
+/
)
||
[
'
0
'
])[
0
])
}
export
function
getWindowTop
()
{
const
style
=
document
.
documentElement
.
style
const
top
=
parseInt
(
style
.
getPropertyValue
(
'
--window-top
'
)
)
const
top
=
getWindowOffsetCssVar
(
style
,
'
--window-top
'
)
return
top
?
top
+
safeAreaInsets
.
top
:
0
}
export
function
getWindowOffset
()
{
const
style
=
document
.
documentElement
.
style
const
top
=
getWindowTop
()
const
bottom
=
parseInt
(
style
.
getPropertyValue
(
'
--window-bottom
'
)
)
const
left
=
parseInt
(
style
.
getPropertyValue
(
'
--window-left
'
)
)
const
right
=
parseInt
(
style
.
getPropertyValue
(
'
--window-right
'
)
)
const
bottom
=
getWindowOffsetCssVar
(
style
,
'
--window-bottom
'
)
const
left
=
getWindowOffsetCssVar
(
style
,
'
--window-left
'
)
const
right
=
getWindowOffsetCssVar
(
style
,
'
--window-right
'
)
return
{
top
,
bottom
:
bottom
?
bottom
+
safeAreaInsets
.
bottom
:
0
,
...
...
packages/uni-core/src/view/plugin/componentInstance.ts
浏览文件 @
878a3868
...
...
@@ -92,7 +92,7 @@ function normalizeClickEvent(
const
{
x
,
y
}
=
mouseEvt
const
top
=
getWindowTop
()
evt
.
detail
=
{
x
,
y
:
y
-
top
}
evt
.
touches
=
evt
.
changedTouches
=
[
createTouchEvent
(
mouseEvt
)]
evt
.
touches
=
evt
.
changedTouches
=
[
createTouchEvent
(
mouseEvt
,
top
)]
}
function
normalizeMouseEvent
(
evt
:
Record
<
string
,
any
>
,
mouseEvt
:
MouseEvent
)
{
...
...
@@ -103,14 +103,14 @@ function normalizeMouseEvent(evt: Record<string, any>, mouseEvt: MouseEvent) {
evt
.
clientY
=
mouseEvt
.
clientY
-
top
}
function
createTouchEvent
(
evt
:
MouseEvent
)
{
function
createTouchEvent
(
evt
:
MouseEvent
,
top
:
number
)
{
return
{
force
:
1
,
identifier
:
0
,
clientX
:
evt
.
clientX
,
clientY
:
evt
.
clientY
,
clientY
:
evt
.
clientY
-
top
,
pageX
:
evt
.
pageX
,
pageY
:
evt
.
pageY
,
pageY
:
evt
.
pageY
-
top
,
}
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
878a3868
...
...
@@ -737,17 +737,20 @@ const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => {
}, ["stop"]);
function getWindowOffsetCssVar(style, name) {
return parseInt((style.getPropertyValue(name).match(/\d+/) || ["0"])[0]);
}
function getWindowTop() {
const style = document.documentElement.style;
const top =
parseInt(style.getPropertyValue("--window-top")
);
const top =
getWindowOffsetCssVar(style, "--window-top"
);
return top ? top + out.top : 0;
}
function getWindowOffset() {
const style = document.documentElement.style;
const top = getWindowTop();
const bottom =
parseInt(style.getPropertyValue("--window-bottom")
);
const left =
parseInt(style.getPropertyValue("--window-left")
);
const right =
parseInt(style.getPropertyValue("--window-right")
);
const bottom =
getWindowOffsetCssVar(style, "--window-bottom"
);
const left =
getWindowOffsetCssVar(style, "--window-left"
);
const right =
getWindowOffsetCssVar(style, "--window-right"
);
return {
top,
bottom: bottom ? bottom + out.bottom : 0,
...
...
@@ -1312,7 +1315,7 @@ function normalizeClickEvent(evt, mouseEvt) {
const { x, y } = mouseEvt;
const top = getWindowTop();
evt.detail = { x, y: y - top };
evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt)];
evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt
, top
)];
}
function normalizeMouseEvent(evt, mouseEvt) {
const top = getWindowTop();
...
...
@@ -1321,14 +1324,14 @@ function normalizeMouseEvent(evt, mouseEvt) {
evt.clientX = mouseEvt.clientX;
evt.clientY = mouseEvt.clientY - top;
}
function createTouchEvent(evt) {
function createTouchEvent(evt
, top
) {
return {
force: 1,
identifier: 0,
clientX: evt.clientX,
clientY: evt.clientY,
clientY: evt.clientY
- top
,
pageX: evt.pageX,
pageY: evt.pageY
pageY: evt.pageY
- top
};
}
function normalizeTouchEvent(touches, top) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录