Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/swipe action on close #6609

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/swipe-action/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Swipe to reveal hidden function menus.

## Demos

<code src="./demos/demo1.tsx"></code>
`<code src="./demos/demo1.tsx"></code>`

## SwipeAction

Expand All @@ -23,6 +23,7 @@ Swipe to reveal hidden function menus.
| onAction | Triggered when operation button is clicked | `(action: Action, e: React.MouseEvent) => void` | - |
| stopPropagation | Stop the propagation of some events. | `PropagationEvent[]` | `[]` |
| onActionsReveal | Triggered when the operation button appears completely | `(side: 'left' \| 'right') => void` | - |
| onActionsClose | Triggered when the slider is closed | `() => void` | - |

### Action

Expand Down
3 changes: 2 additions & 1 deletion src/components/swipe-action/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 示例

<code src="./demos/demo1.tsx"></code>
`<code src="./demos/demo1.tsx"></code>`

## SwipeAction

Expand All @@ -23,6 +23,7 @@
| onAction | 点击操作按钮时触发 | `(action: Action, e: React.MouseEvent) => void` | - |
| stopPropagation | 阻止某些事件的冒泡 | `PropagationEven[]` | `[]` |
| onActionsReveal | 按钮完全出现时触发 | `(side: 'left' \| 'right') => void` | - |
| onActionsClose | 滑块关闭时触发 | `() => void` | - |

### Action

Expand Down
2 changes: 2 additions & 0 deletions src/components/swipe-action/swipe-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type SwipeActionProps = {
children: ReactNode
stopPropagation?: PropagationEvent[]
onActionsReveal?: (side: SideType) => void
onActionsClose?: () => void
} & NativeProps<'--background'>

const defaultProps = {
Expand Down Expand Up @@ -155,6 +156,7 @@ export const SwipeAction = forwardRef<SwipeActionRef, SwipeActionProps>(
x: 0,
})
forceCancelDrag()
p?.onActionsClose?.()
}

useImperativeHandle(ref, () => ({
Expand Down