SwipeCell
Left and right action panels, exclusive within each page, with an asynchronous close guard. Outside interactions close the panel directly.
Import
With uni-app easycom, use hui-swipe-cell。 Standalone Vue imports @nscode/handy-uni/web HuiSwipeCell or installs the preview plugin.
Examples
Interaction and event results
Interact with the control. The latest event and its full payload are shown below. Popup selectors commit only after confirmation; cancellation keeps the previous value.
vue
<script setup lang="ts">
import { ref } from 'vue'
const result = ref('')
function event0(arg0: unknown) {
result.value = 'update:opened' + ': ' + JSON.stringify([arg0])
}
function event1(arg0: unknown) {
result.value = 'open' + ': ' + JSON.stringify([arg0])
}
function event2(arg0: unknown) {
result.value = 'close' + ': ' + JSON.stringify([arg0])
}
function event3(arg0: unknown) {
result.value = 'click' + ': ' + JSON.stringify([arg0])
}
</script>
<template>
<view>
<hui-swipe-cell
:right-width="88"
@update:opened="event0"
@open="event1"
@close="event2"
@click="event3"
><view style="padding: 20px">左右滑动 / Swipe</view
><template #right="{ close }"
><button @click="close('right')">完成 / Done</button></template
></hui-swipe-cell
>
<text aria-live="polite">{{ result }}</text>
</view>
</template>
Props
| Property | Type | Default | Description |
|---|---|---|---|
opened | SwipeCellSide | null | undefined | undefined | Controlled opened side, left/right or null. |
default-opened | SwipeCellSide | null | undefined | null | Initially opened side. |
name | readonly [StringConstructor, NumberConstructor] | undefined | — | Application identifier included in events. |
disabled | boolean | undefined | false | Disable user interaction, including inherited form state. |
left-width | number | undefined | — | Left action width, measured and cached when omitted. |
right-width | number | undefined | — | Right action width, measured and cached when omitted. |
threshold | number | undefined | 0.15 | Action-width fraction required to settle open. |
before-close | ((context: SwipeCellCloseContext) => boolean | void | Promise<boolean | void>) | undefined | — | Close guard; outside and exclusive closing bypass it. |
exclusive | boolean | undefined | true | Close other cells when opening within the same page. |
close-on-click-action | boolean | undefined | true | Request closing after an action click. |
custom-class | string | undefined | '' | Additional root classes. |
custom-style | string | CSSProperties | undefined | — | Additional root styles. |
Events
| Event | Parameters | Description |
|---|---|---|
update:opened | (side: SwipeCellSide | null) | Requests a controlled value update. |
open | (info: { name?: string | number | undefined; side: SwipeCellSide; }) | Reports open with the arguments shown in the example. |
close | (context: SwipeCellCloseContext) | Reports close with the arguments shown in the example. |
click | (info: { name?: string | number | undefined; position: SwipeCellSide | "cell"; }) | Reports click with the arguments shown in the example. |
Slots
| Slot | Description |
|---|---|
left | Left actions, scope {close}. |
default | Default content. |
right | Right actions, scope {close}. |
Methods
| Method | Signature |
|---|---|
open | (side: SwipeCellSide) => void |
close | (position?: SwipeCellPosition | undefined) => Promise<boolean> |
Types
SwipeCellProps、SwipeCellEmits、SwipeCellExpose。 Public types are exported from the package entry.
Platform notes
| Scope | Behavior and validation limits |
|---|---|
| Shared implementation | Uses touch direction locking and displacement to reveal actions. Scoped slots receive close; business deletion requires confirmation. |
| Device checks pending | Check horizontal versus page scrolling, async close, rapid reopening and closing after actions; also check mouse interaction on Web. |
See examples/uni-demo/smoke/SwipeCell.md for the checklist. Unit tests do not replace device acceptance.