Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
48007964
U
uni-app
项目概览
wzj-java
/
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,发现更多精彩内容 >>
提交
48007964
编写于
2月 15, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(nvue): movable
上级
4425afc8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
94 addition
and
79 deletion
+94
-79
packages/uni-components/dist/components.js
packages/uni-components/dist/components.js
+43
-36
packages/uni-components/src/nvue/movable-area/index.tsx
packages/uni-components/src/nvue/movable-area/index.tsx
+1
-1
packages/uni-components/src/nvue/movable-view/index.tsx
packages/uni-components/src/nvue/movable-view/index.tsx
+22
-18
packages/uni-components/src/nvue/movable-view/useTouchtrack.ts
...ges/uni-components/src/nvue/movable-view/useTouchtrack.ts
+28
-24
未找到文件。
packages/uni-components/dist/components.js
浏览文件 @
48007964
...
...
@@ -709,32 +709,23 @@ var MovableArea = defineComponent({
};
}
});
const
__event
=
{};
function
callback
(
type
,
$event
)
{
if
(
__event
[
type
])
{
__event
[
type
](
$event
);
function
useTouchtrack
(
method
)
{
const
__event
=
{};
function
callback
(
type
,
$event
)
{
if
(
__event
[
type
])
{
__event
[
type
](
$event
);
}
}
}
function
addListener
(
type
,
callback2
)
{
__event
[
type
]
=
function
(
$event
)
{
if
(
typeof
callback2
===
"
function
"
)
{
$event
.
touches
=
$event
.
changedTouches
;
if
(
callback2
(
$event
)
===
false
)
{
$event
.
stopPropagation
();
function
addListener
(
type
,
callback2
)
{
__event
[
type
]
=
function
(
$event
)
{
if
(
typeof
callback2
===
"
function
"
)
{
$event
.
touches
=
$event
.
changedTouches
;
if
(
callback2
(
$event
)
===
false
)
{
$event
.
stopPropagation
();
}
}
}
};
}
function
touchstart
(
$event
)
{
callback
(
"
touchstart
"
,
$event
);
}
function
touchmove
(
$event
)
{
callback
(
"
touchmove
"
,
$event
);
}
function
touchend
(
$event
)
{
callback
(
"
touchend
"
,
$event
);
}
function
useTouchtrack
(
method
)
{
};
}
let
x0
=
0
;
let
y0
=
0
;
let
x1
=
0
;
...
...
@@ -783,6 +774,17 @@ function useTouchtrack(method) {
return
fn
(
$event
,
"
end
"
,
$event
.
changedTouches
[
0
].
pageX
,
$event
.
changedTouches
[
0
].
pageY
);
}
});
return
{
touchstart
:
function
(
$event
)
{
callback
(
"
touchstart
"
,
$event
);
},
touchmove
:
function
(
$event
)
{
callback
(
"
touchmove
"
,
$event
);
},
touchend
:
function
(
$event
)
{
callback
(
"
touchend
"
,
$event
);
}
};
}
function
useCustomEvent
(
ref2
,
emit
)
{
return
(
name
,
detail
)
=>
{
...
...
@@ -1215,8 +1217,8 @@ function _requestAnimationFrame(e2) {
});
}
}
function
requestAnimationFrame
(
callback
2
)
{
return
setTimeout
(
callback
2
,
16
);
function
requestAnimationFrame
(
callback
)
{
return
setTimeout
(
callback
,
16
);
}
function
cancelAnimationFrame
(
id
)
{
clearTimeout
(
id
);
...
...
@@ -1243,14 +1245,7 @@ var MovableView = defineComponent({
const
trigger
=
useCustomEvent
(
rootRef
,
emit
);
const
setTouchMovableViewContext
=
inject
(
"
setTouchMovableViewContext
"
,
()
=>
{
});
useMovableViewState
(
props
,
trigger
,
rootRef
);
const
touchStart
=
()
=>
{
setTouchMovableViewContext
({
touchstart
,
touchmove
,
touchend
});
};
const
touchStart
=
useMovableViewState
(
props
,
trigger
,
rootRef
,
setTouchMovableViewContext
);
return
()
=>
{
const
attrs
=
{
preventGesture
:
true
...
...
@@ -1264,7 +1259,7 @@ var MovableView = defineComponent({
};
}
});
function
useMovableViewState
(
props
,
trigger
,
rootRef
)
{
function
useMovableViewState
(
props
,
trigger
,
rootRef
,
setTouchMovableViewContext
)
{
const
_isMounted
=
inject
(
"
_isMounted
"
,
ref
(
false
));
const
parentSize
=
inject
(
"
parentSize
"
,
{
width
:
ref
(
0
),
...
...
@@ -1276,6 +1271,14 @@ function useMovableViewState(props, trigger, rootRef) {
});
const
removeMovableViewContext
=
inject
(
"
removeMovableViewContext
"
,
()
=>
{
});
let
movableViewContext
=
{
touchstart
:
()
=>
{
},
touchmove
:
()
=>
{
},
touchend
:
()
=>
{
}
};
function
_getPx
(
val
)
{
return
Number
(
val
)
||
0
;
}
...
...
@@ -1713,7 +1716,7 @@ function useMovableViewState(props, trigger, rootRef) {
_setTransform
(
x
,
y
,
scale
,
""
,
true
);
}
onMounted
(()
=>
{
useTouchtrack
((
event
)
=>
{
movableViewContext
=
useTouchtrack
((
event
)
=>
{
switch
(
event
.
detail
.
state
)
{
case
"
start
"
:
__handleTouchStart
();
...
...
@@ -1743,6 +1746,10 @@ function useMovableViewState(props, trigger, rootRef) {
onUnmounted
(()
=>
{
FAandSFACancel
();
});
const
touchStart
=
()
=>
{
setTouchMovableViewContext
(
movableViewContext
);
};
return
touchStart
;
}
var
components
=
{
Navigator
,
...
...
packages/uni-components/src/nvue/movable-area/index.tsx
浏览文件 @
48007964
...
...
@@ -9,7 +9,7 @@ export interface MovableViewContext {
export
type
AddMovableViewContext
=
(
context
:
MovableViewContext
)
=>
void
export
type
RemoveMovableViewContext
=
(
context
:
MovableViewContext
)
=>
void
interface
TouchMovableViewContext
{
export
interface
TouchMovableViewContext
{
touchstart
:
(
e
:
TouchtrackEvent
)
=>
void
touchmove
:
(
e
:
TouchtrackEvent
)
=>
void
touchend
:
(
e
:
TouchtrackEvent
)
=>
void
...
...
packages/uni-components/src/nvue/movable-view/index.tsx
浏览文件 @
48007964
...
...
@@ -8,13 +8,7 @@ import {
inject
,
watch
,
}
from
'
vue
'
import
{
useTouchtrack
,
touchstart
,
touchmove
,
touchend
,
TouchtrackEvent
,
}
from
'
./useTouchtrack
'
import
{
useTouchtrack
,
TouchtrackEvent
}
from
'
./useTouchtrack
'
import
{
CustomEventTrigger
,
EmitEvent
,
...
...
@@ -25,6 +19,7 @@ import {
AddMovableViewContext
,
RemoveMovableViewContext
,
SetTouchMovableViewContext
,
TouchMovableViewContext
,
parentSize
,
}
from
'
../movable-area
'
import
{
...
...
@@ -133,15 +128,12 @@ export default defineComponent({
'
setTouchMovableViewContext
'
,
()
=>
{}
)
useMovableViewState
(
props
,
trigger
,
rootRef
)
const
touchStart
=
()
=>
{
setTouchMovableViewContext
({
touchstart
,
touchmove
,
touchend
,
})
}
const
touchStart
=
useMovableViewState
(
props
,
trigger
,
rootRef
,
setTouchMovableViewContext
)
return
()
=>
{
const
attrs
=
{
...
...
@@ -165,7 +157,8 @@ export default defineComponent({
function
useMovableViewState
(
props
:
Props
,
trigger
:
CustomEventTrigger
,
rootRef
:
RootRef
rootRef
:
RootRef
,
setTouchMovableViewContext
:
SetTouchMovableViewContext
)
{
const
_isMounted
:
Ref
<
boolean
>
=
inject
(
'
_isMounted
'
,
ref
(
false
))
const
parentSize
:
parentSize
=
inject
(
'
parentSize
'
,
{
...
...
@@ -182,6 +175,11 @@ function useMovableViewState(
'
removeMovableViewContext
'
,
()
=>
{}
)
let
movableViewContext
:
TouchMovableViewContext
=
{
touchstart
:
()
=>
{},
touchmove
:
()
=>
{},
touchend
:
()
=>
{},
}
function
_getPx
(
val
:
string
|
number
)
{
// if (/\d+[ur]px$/i.test(val)) {
// return uni.upx2px(parseFloat(val))
...
...
@@ -693,7 +691,7 @@ function useMovableViewState(
}
onMounted
(()
=>
{
useTouchtrack
((
event
)
=>
{
movableViewContext
=
useTouchtrack
((
event
)
=>
{
switch
(
event
.
detail
.
state
)
{
case
'
start
'
:
__handleTouchStart
()
...
...
@@ -729,4 +727,10 @@ function useMovableViewState(
onUnmounted
(()
=>
{
FAandSFACancel
()
})
const
touchStart
=
()
=>
{
setTouchMovableViewContext
(
movableViewContext
)
}
return
touchStart
}
packages/uni-components/src/nvue/movable-view/useTouchtrack.ts
浏览文件 @
48007964
...
...
@@ -21,34 +21,26 @@ export interface TouchtrackEvent {
detail
:
Detail
}
const
__event
:
Record
<
string
,
Function
>
=
{}
function
callback
(
type
:
CallbackType
,
$event
:
TouchtrackEvent
)
{
if
(
__event
[
type
])
{
__event
[
type
](
$event
)
export
function
useTouchtrack
(
method
:
(
event
:
TouchtrackEvent
)
=>
boolean
|
void
)
{
const
__event
:
Record
<
string
,
Function
>
=
{}
function
callback
(
type
:
CallbackType
,
$event
:
TouchtrackEvent
)
{
if
(
__event
[
type
])
{
__event
[
type
](
$event
)
}
}
}
function
addListener
(
type
:
CallbackType
,
callback
:
Function
)
{
__event
[
type
]
=
function
(
$event
:
TouchtrackEvent
)
{
if
(
typeof
callback
===
'
function
'
)
{
$event
.
touches
=
$event
.
changedTouches
if
(
callback
(
$event
)
===
false
)
{
$event
.
stopPropagation
()
function
addListener
(
type
:
CallbackType
,
callback
:
Function
)
{
__event
[
type
]
=
function
(
$event
:
TouchtrackEvent
)
{
if
(
typeof
callback
===
'
function
'
)
{
$event
.
touches
=
$event
.
changedTouches
if
(
callback
(
$event
)
===
false
)
{
$event
.
stopPropagation
()
}
}
}
}
}
export
function
touchstart
(
$event
:
TouchtrackEvent
)
{
callback
(
'
touchstart
'
,
$event
)
}
export
function
touchmove
(
$event
:
TouchtrackEvent
)
{
callback
(
'
touchmove
'
,
$event
)
}
export
function
touchend
(
$event
:
TouchtrackEvent
)
{
callback
(
'
touchend
'
,
$event
)
}
export
function
useTouchtrack
(
method
:
(
event
:
TouchtrackEvent
)
=>
boolean
|
void
)
{
let
x0
=
0
let
y0
=
0
let
x1
=
0
...
...
@@ -115,4 +107,16 @@ export function useTouchtrack(
)
}
})
return
{
touchstart
:
function
(
$event
:
TouchtrackEvent
)
{
callback
(
'
touchstart
'
,
$event
)
},
touchmove
:
function
(
$event
:
TouchtrackEvent
)
{
callback
(
'
touchmove
'
,
$event
)
},
touchend
:
function
(
$event
:
TouchtrackEvent
)
{
callback
(
'
touchend
'
,
$event
)
},
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录