Swipeout Svelte 组件
Swipeout 列表不是一个单独的组件,而只是使用<List>, <ListItem swipeout>Svelte 组件和额外的 Swipeout 组件。
Swipeout Svelte 组件代表 Framework7 的滑动删除组件。
Swipeout 组件
包含以下组件:
SwipeoutActions
- swipeout 按钮的包装器SwipeoutButton
- 单个 swipeout 按钮
Swipeout 属性
属性 | 类型 | 默认 | 描述 |
---|---|---|---|
<SwipeoutActions> 属性 | |||
侧 | 字符串 | 右 | Swipeout 动作侧 |
右 | 布尔值 | 快捷方式side="right" prop | |
左 | 布尔值 | 快捷方式side="left" prop | |
<SwipeoutButton> 属性 | |||
删除 | 布尔值 | false | 点击时将自动删除 swipeout 列表项 |
close | 布尔值 | false | 点击时将自动关闭 swipeout 列表项 |
溢出 | 布尔值 | false | 如果你滑动动作过多,将自动触发点击 -溢出 |
text | 字符串 | Swipeout 按钮文本标签 | |
confirmText | 字符串 | 此文本将在用户同意删除项目之前显示在对话框中 | |
confirmTitle | 字符串 | 此文本将显示为对话框标题,用户必须在删除项目前同意 |
Swipeout 事件
事件 | 描述 |
---|---|
<SwipeoutButton> 事件 | |
click | 点击 swipeout 按钮时将触发事件 |
<ListItem> 事件 在带有 swipeout 启用 | |
swipeout | 滑动 swipeout 元素时将触发事件。event.detail.progress包含当前打开的进度百分比 |
swipeoutOpen | 当滑动删除元素开始其打开动画时将触发事件 |
swipeoutOpened | 当滑动删除元素完成其打开动画后触发事件 |
swipeoutClose | 当滑动删除元素开始其关闭动画时将触发事件 |
swipeoutClosed | 当滑动删除元素完成其删除动画后触发事件 |
swipeoutDelete | 当滑动删除元素开始其删除动画后触发事件 |
swipeoutDeleted | 当滑动删除元素完成其删除动画后触发事件,就在它将被从 DOM 中移除之前 |
swipeoutOverswipeEnter | 当启用溢出时将触发事件 |
swipeoutOverswipeExit | 当禁用溢出时将触发事件 |
示例
swipeout.svelte
<script>
import {
f7,
Navbar,
Page,
BlockTitle,
List,
ListItem,
SwipeoutActions,
SwipeoutButton,
Block,
} from 'framework7-svelte';
let actions;
function more() {
actions.open();
}
function mark() {
f7.dialog.alert('Mark');
}
function reply() {
f7.dialog.alert('Reply');
}
function forward() {
f7.dialog.alert('Forward');
}
function onDeleted() {
f7.dialog.alert('Thanks, item removed!');
}
function onPageBeforeRemove() {
actions.destroy();
}
function onPageInit() {
actions = f7.actions.create({
buttons: [
[
{
text: 'Here comes some optional description or warning for actions below',
label: true,
},
{
text: 'Action 1',
},
{
text: 'Action 2',
},
],
[
{
text: 'Cancel',
strong: true,
},
],
],
});
}
</script>
<Page {onPageBeforeRemove} {onPageInit}>
<Navbar title="Swipeout" />
<Block>
<p>
Swipe out actions on list elements is one of the most awesome F7 features. It allows you to
call hidden menu for each list element where you can put default ready-to use delete button or
any other buttons for some required actions.
</p>
</Block>
<BlockTitle>Swipe to delete with confirm modal</BlockTitle>
<List strong insetMd outlineIos dividersIos>
<ListItem swipeout title="Swipe left on me please">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton delete confirmText="Are you sure you want to delete this item?">
Delete
</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem swipeout title="Swipe left on me too">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton delete confirmText="Are you sure you want to delete this item?">
Delete
</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem title="I am not removable"><i slot="media" class="icon icon-f7" /></ListItem>
</List>
<BlockTitle>Swipe to delete without confirm</BlockTitle>
<List strong insetMd outlineIos dividersIos>
<ListItem swipeout title="Swipe left on me please">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem swipeout title="Swipe left on me too">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem title="I am not removable"><i slot="media" class="icon icon-f7" /></ListItem>
</List>
<BlockTitle>Swipe for actions</BlockTitle>
<List strong insetMd outlineIos dividersIos>
<ListItem swipeout title="Swipe left on me please">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem swipeout title="Swipe left on me too">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem swipeout title="You can't delete me">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
</SwipeoutActions>
</ListItem>
</List>
<BlockTitle>With callback on remove</BlockTitle>
<List strong insetMd outlineIos dividersIos>
<ListItem swipeout onSwipeoutDeleted={onDeleted} title="Swipe left on me please">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem swipeout onSwipeoutDeleted={onDeleted} title="Swipe left on me too">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem title="I am not removable"><i slot="media" class="icon icon-f7" /></ListItem>
</List>
<BlockTitle>With actions on left side (swipe to right)</BlockTitle>
<List strong insetMd outlineIos dividersIos>
<ListItem swipeout title="Swipe right on me please">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions left>
<SwipeoutButton color="green" onClick={reply}>Reply</SwipeoutButton>
<SwipeoutButton color="blue" onClick={forward}>Forward</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem swipeout title="Swipe right on me too">
<i slot="media" class="icon icon-f7" />
<SwipeoutActions left>
<SwipeoutButton color="green" onClick={reply}>Reply</SwipeoutButton>
<SwipeoutButton color="blue" onClick={forward}>Forward</SwipeoutButton>
</SwipeoutActions>
</ListItem>
</List>
<BlockTitle>On both sides with overswipes</BlockTitle>
<List mediaList strong insetMd outlineIos dividersIos>
<ListItem
swipeout
title="Facebook"
after="17:14"
subtitle="New messages from John Doe"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
>
<SwipeoutActions left>
<SwipeoutButton overswipe color="green" onClick={reply}>Reply</SwipeoutButton>
<SwipeoutButton color="blue" onClick={forward}>Forward</SwipeoutButton>
</SwipeoutActions>
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton color="orange" onClick={mark}>Mark</SwipeoutButton>
<SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">
Delete
</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
swipeout
title="John Doe (via Twitter)"
after="17:11"
subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
>
<SwipeoutActions left>
<SwipeoutButton overswipe color="green" onClick={reply}>Reply</SwipeoutButton>
<SwipeoutButton color="blue" onClick={forward}>Forward</SwipeoutButton>
</SwipeoutActions>
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton color="orange" onClick={mark}>Mark</SwipeoutButton>
<SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">
Delete
</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
swipeout
title="Facebook"
after="16:48"
subtitle="New messages from John Doe"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
>
<SwipeoutActions left>
<SwipeoutButton overswipe color="green" onClick={reply}>Reply</SwipeoutButton>
<SwipeoutButton color="blue" onClick={forward}>Forward</SwipeoutButton>
</SwipeoutActions>
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton color="orange" onClick={mark}>Mark</SwipeoutButton>
<SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">
Delete
</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
swipeout
title="John Doe (via Twitter)"
after="15:32"
subtitle="John Doe (@_johndoe) mentioned you on Twitter!"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
>
<SwipeoutActions left>
<SwipeoutButton overswipe color="green" onClick={reply}>Reply</SwipeoutButton>
<SwipeoutButton color="blue" onClick={forward}>Forward</SwipeoutButton>
</SwipeoutActions>
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton color="orange" onClick={mark}>Mark</SwipeoutButton>
<SwipeoutButton delete overswipe confirmText="Are you sure you want to delete this item?">
Delete
</SwipeoutButton>
</SwipeoutActions>
</ListItem>
</List>
</Page>