Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
京东前端
nutui-react
提交
58f83a7a
N
nutui-react
项目概览
京东前端
/
nutui-react
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nutui-react
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
58f83a7a
编写于
2月 13, 2023
作者:
O
oasis-cloud
提交者:
GitHub
2月 13, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: swipe 组件对外暴露 onTouchStart onTouchMove onTouchEnd 事件 (#656)
上级
a7059009
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
54 addition
and
23 deletion
+54
-23
src/packages/swipe/demo.taro.tsx
src/packages/swipe/demo.taro.tsx
+3
-0
src/packages/swipe/demo.tsx
src/packages/swipe/demo.tsx
+3
-0
src/packages/swipe/doc.en-US.md
src/packages/swipe/doc.en-US.md
+3
-1
src/packages/swipe/doc.md
src/packages/swipe/doc.md
+8
-6
src/packages/swipe/doc.taro.md
src/packages/swipe/doc.taro.md
+3
-0
src/packages/swipe/doc.zh-TW.md
src/packages/swipe/doc.zh-TW.md
+8
-10
src/packages/swipe/swipe.taro.tsx
src/packages/swipe/swipe.taro.tsx
+13
-3
src/packages/swipe/swipe.tsx
src/packages/swipe/swipe.tsx
+13
-3
未找到文件。
src/packages/swipe/demo.taro.tsx
浏览文件 @
58f83a7a
...
...
@@ -164,6 +164,9 @@ const SwipeDemo = () => {
{
translated
.
del
}
</
Button
>
}
onTouchEnd
=
{
(
e
)
=>
console
.
log
(
e
)
}
onTouchMove
=
{
(
e
)
=>
console
.
log
(
e
)
}
onTouchStart
=
{
(
e
)
=>
console
.
log
(
e
)
}
>
<
Cell
title
=
{
translated
.
leftDel
}
roundRadius
=
{
0
}
/>
</
Swipe
>
...
...
src/packages/swipe/demo.tsx
浏览文件 @
58f83a7a
...
...
@@ -151,6 +151,9 @@ const SwipeDemo = () => {
{
translated
.
del
}
</
Button
>
}
onTouchStart
=
{
(
event
)
=>
console
.
log
(
'
touch start
'
,
event
)
}
onTouchMove
=
{
(
event
)
=>
console
.
log
(
'
touch Move
'
,
event
)
}
onTouchEnd
=
{
(
event
)
=>
console
.
log
(
'
touch End
'
,
event
)
}
>
<
Cell
title
=
{
translated
.
leftDel
}
roundRadius
=
{
0
}
/>
</
Swipe
>
...
...
src/packages/swipe/doc.en-US.md
浏览文件 @
58f83a7a
...
...
@@ -217,7 +217,9 @@ export default App;
|onOpen | open the cell sidebar |_name: string , position:
`left \| right`
_ |
|onClose | collapse the cell sidebar |_name: string , position:
`left \| right`
_ |
|onActionClick | triggered when clicking on the left or right |_event: Event , position:
`left \| right`
_ |
| onTouchStart
`v1.4.7`
| ontouchStart | _event: Event |
| onTouchMove
`v1.4.7`
| ontouchmove | _event: Event |
| onTouchEnd
`v1.4.7`
| ontouchend | _event: Event |
## Theming
### CSS Variables
...
...
src/packages/swipe/doc.md
浏览文件 @
58f83a7a
...
...
@@ -201,12 +201,14 @@ export default App;
### Events
| 事件名 | 说明 | 回调参数 |
|--------|----------------|--------------|
| onOpen | 打开单元格侧边栏 | _name: string , position:
`left \| right`
_ |
| onClose | 收起单元格侧边栏 | _name: string , position:
`left \| right`
_ |
| onActionClick | 点击左侧或者右侧时触发 | _event: Event , position:
`left \| right`
_ |
| 事件名 | 说明 | 回调参数 |
|---------------|--------------|--------------|
| onOpen | 打开单元格侧边栏 | _name: string , position:
`left \| right`
_ |
| onClose | 收起单元格侧边栏 | _name: string , position:
`left \| right`
_ |
| onActionClick | 点击左侧或者右侧时触发 | _event: Event , position:
`left \| right`
_ |
| onTouchStart
`v1.4.7`
| ontouchStart | _event: Event |
| onTouchMove
`v1.4.7`
| ontouchmove | _event: Event |
| onTouchEnd
`v1.4.7`
| ontouchend | _event: Event |
## 主题定制
...
...
src/packages/swipe/doc.taro.md
浏览文件 @
58f83a7a
...
...
@@ -205,6 +205,9 @@ export default App;
| onOpen | 打开单元格侧边栏 | _name: string , position:
`left \| right`
_ |
| onClose | 收起单元格侧边栏 | _name: string , position:
`left \| right`
_ |
| onActionClick | 点击左侧或者右侧时触发 | _event: Event , position:
`left \| right`
_ |
| onTouchStart
`v1.4.7`
| ontouchStart | _event: Event |
| onTouchMove
`v1.4.7`
| ontouchmove | _event: Event |
| onTouchEnd
`v1.4.7`
| ontouchend | _event: Event |
## 主题定制
...
...
src/packages/swipe/doc.zh-TW.md
浏览文件 @
58f83a7a
...
...
@@ -200,16 +200,14 @@ export default App;
### Events
|事件名|說明|回檔參數|
|--------|----------------|--------------|
| onOpen |打開儲存格側邊欄| _name: string,position:
`left \| right`
_ |
| onClose |收起儲存格側邊欄| _name: string,position:
`left \| right`
_ |
| onActionClick |點擊左側或者右側時觸發| _event: Event,position:
`left \| right`
_ |
| 事件名 | 說明 |回檔參數|
|---------------------|--------------|--------------|
| onOpen | 打開儲存格側邊欄 | _name: string,position:
`left \| right`
_ |
| onClose | 收起儲存格側邊欄 | _name: string,position:
`left \| right`
_ |
| onActionClick | 點擊左側或者右側時觸發 | _event: Event,position:
`left \| right`
_ |
| onTouchStart
`v1.4.7`
| ontouchStart | _event: Event |
| onTouchMove
`v1.4.7`
| ontouchmove | _event: Event |
| onTouchEnd
`v1.4.7`
| ontouchend | _event: Event |
## 主題定制
...
...
src/packages/swipe/swipe.taro.tsx
浏览文件 @
58f83a7a
...
...
@@ -66,6 +66,9 @@ export interface SwipeProps {
})
=>
void
/** 点击时触发 */
onActionClick
?:
(
event
:
Event
,
position
:
SwipePosition
)
=>
void
onTouchStart
?:
(
event
:
Event
)
=>
void
onTouchEnd
?:
(
event
:
Event
)
=>
void
onTouchMove
?:
(
event
:
Event
)
=>
void
children
?:
React
.
ReactNode
}
const
defaultProps
=
{
...
...
@@ -75,7 +78,11 @@ const defaultProps = {
}
as
SwipeProps
export
const
Swipe
=
forwardRef
<
SwipeInstance
,
Partial
<
SwipeProps
>
&
React
.
HTMLAttributes
<
HTMLDivElement
>
Partial
<
SwipeProps
>
&
Omit
<
React
.
HTMLAttributes
<
HTMLDivElement
>
,
'
onTouchStart
'
|
'
onTouchMove
'
|
'
onTouchEnd
'
>
>
((
props
,
instanceRef
)
=>
{
const
swipeBem
=
bem
(
'
swipe
'
)
const
touch
:
any
=
useTouch
()
...
...
@@ -122,6 +129,7 @@ export const Swipe = forwardRef<
if
(
!
props
.
disabled
)
{
startOffset
.
current
=
state
.
offset
touch
.
start
(
event
)
props
.
onTouchStart
&&
props
.
onTouchStart
(
event
)
}
}
...
...
@@ -131,6 +139,7 @@ export const Swipe = forwardRef<
}
touch
.
move
(
event
)
props
.
onTouchMove
&&
props
.
onTouchMove
(
event
)
if
(
touch
.
isHorizontal
())
{
lockClick
.
current
=
true
...
...
@@ -149,13 +158,14 @@ export const Swipe = forwardRef<
}
}
const
onTouchEnd
=
()
=>
{
const
onTouchEnd
=
(
event
:
Event
)
=>
{
if
(
state
.
dragging
)
{
setState
((
v
)
=>
({
...
v
,
dragging
:
false
}))
toggle
(
state
.
offset
>
0
?
'
left
'
:
'
right
'
)
setTimeout
(()
=>
{
lockClick
.
current
=
false
},
0
)
props
.
onTouchEnd
&&
props
.
onTouchEnd
(
event
)
}
}
...
...
@@ -278,7 +288,7 @@ export const Swipe = forwardRef<
className
=
{
`
${
swipeBem
()}
${
className
}
`
}
onTouchStart
=
{
(
e
:
any
)
=>
onTouchStart
(
e
)
}
onTouchMove
=
{
(
e
:
any
)
=>
onTouchMove
(
e
)
}
onTouchEnd
=
{
onTouchEnd
}
onTouchEnd
=
{
(
e
:
any
)
=>
onTouchEnd
(
e
)
}
style
=
{
style
}
>
<
div
className
=
{
`
${
swipeBem
(
'
wrapper
'
)}
`
}
style
=
{
wrapperStyle
}
>
...
...
src/packages/swipe/swipe.tsx
浏览文件 @
58f83a7a
...
...
@@ -67,6 +67,9 @@ export interface SwipeProps {
})
=>
void
/** 点击时触发 */
onActionClick
?:
(
event
:
Event
,
position
:
SwipePosition
)
=>
void
onTouchStart
?:
(
event
:
Event
)
=>
void
onTouchEnd
?:
(
event
:
Event
)
=>
void
onTouchMove
?:
(
event
:
Event
)
=>
void
children
?:
React
.
ReactNode
}
const
defaultProps
=
{
...
...
@@ -76,7 +79,11 @@ const defaultProps = {
}
as
SwipeProps
export
const
Swipe
=
forwardRef
<
SwipeInstance
,
Partial
<
SwipeProps
>
&
React
.
HTMLAttributes
<
HTMLDivElement
>
Partial
<
SwipeProps
>
&
Omit
<
React
.
HTMLAttributes
<
HTMLDivElement
>
,
'
onTouchStart
'
|
'
onTouchMove
'
|
'
onTouchEnd
'
>
>
((
props
,
instanceRef
)
=>
{
const
swipeBem
=
bem
(
'
swipe
'
)
const
touch
:
any
=
useTouch
()
...
...
@@ -114,6 +121,7 @@ export const Swipe = forwardRef<
if
(
!
props
.
disabled
)
{
startOffset
.
current
=
state
.
offset
touch
.
start
(
event
)
props
.
onTouchStart
&&
props
.
onTouchStart
(
event
)
}
}
...
...
@@ -123,6 +131,7 @@ export const Swipe = forwardRef<
}
touch
.
move
(
event
)
props
.
onTouchMove
&&
props
.
onTouchMove
(
event
)
if
(
touch
.
isHorizontal
())
{
lockClick
.
current
=
true
...
...
@@ -142,7 +151,7 @@ export const Swipe = forwardRef<
}
}
const
onTouchEnd
=
()
=>
{
const
onTouchEnd
=
(
event
:
Event
)
=>
{
if
(
state
.
dragging
)
{
setState
((
v
)
=>
({
...
v
,
dragging
:
false
}))
toggle
(
state
.
offset
>
0
?
'
left
'
:
'
right
'
)
...
...
@@ -150,6 +159,7 @@ export const Swipe = forwardRef<
setTimeout
(()
=>
{
lockClick
.
current
=
false
},
0
)
props
.
onTouchEnd
&&
props
.
onTouchEnd
(
event
)
}
}
...
...
@@ -270,7 +280,7 @@ export const Swipe = forwardRef<
className
=
{
`
${
swipeBem
()}
${
className
}
`
}
onTouchStart
=
{
(
e
:
any
)
=>
onTouchStart
(
e
)
}
onTouchMove
=
{
(
e
:
any
)
=>
onTouchMove
(
e
)
}
onTouchEnd
=
{
onTouchEnd
}
onTouchEnd
=
{
(
e
:
any
)
=>
onTouchEnd
(
e
)
}
style
=
{
style
}
>
<
div
className
=
{
`
${
swipeBem
(
'
wrapper
'
)}
`
}
style
=
{
wrapperStyle
}
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录