スワイプアウト・Svelte・コンポーネント(Swipeout Svelte Component
Swipeout Listは独立したコンポーネントではなく、<List>、<ListItem swipeout>のSvelteコンポーネントと、追加のSwipeoutコンポーネントを使用した特殊なケースです。
Swipeout Svelteコンポーネントは、Framework7のSwipeoutコンポーネントを表しています。
Swipeoutコンポーネント
以下のコンポーネントが含まれています。
SwipeoutActions
- スワイプアウトボタンのラッパーSwipeoutButton
- 単一のスワイプアウトボタン
スワイプアウトのプロパティ
Prop | Type | Default | Description |
---|---|---|---|
<SwipeoutActions> Properties | |||
side | string | right | スワイプアウトアクションのサイド |
right | boolean | side="right"` のショートカットです。 | |
left | boolean | side="left"` ディレクティブのショートカットです。 | |
<SwipeoutButton> Properties | |||
delete | boolean | false | クリックするとスワイプアウトリストのアイテムを自動的に削除します。 |
close | boolean | false | クリックすると自動的にスワイプアウトリストのアイテムを閉じます |
overswipe | boolean | false | スワイプ操作をしすぎると自動的にクリックされるようになる - overswipe |
text | string | スワイプアウトボタンのテキストラベル | |
confirmText | string | このテキストは、アイテムを削除する前にユーザーが同意しなければならないダイアログに表示されます。 | |
confirmTitle | string | このテキストは、アイテムを削除する前にユーザーが同意しなければならないダイアログのタイトルとして表示されます。 |
スワイプアウトイベント
Event | Description |
---|---|
<SwipeoutButton> events | |
click | スワイプアウトボタンがクリックされるとイベントが発生します。 |
<ListItem> events The following events will be available on <ListItem> with swipeout enabled | |
swipeout | スワイプアウト要素を移動するとイベントが発生します。event.detail.progressには、現在の開いた状態の進捗率が表示されます。 |
swipeoutOpen | イベントは、スワイプアウト要素が開くアニメーションを開始するときにトリガされます。 |
swipeoutOpened | イベントは、スワイプアウト要素がオープニングアニメーションを完了した後に発生します。 |
swipeoutClose | イベントは、スワイプアウト要素が閉じるアニメーションを開始したときにトリガされます。 |
swipeoutClosed | イベントはスワイプアウト要素が閉じるアニメーションを完了した後にトリガされます。 |
swipeoutDelete | スワイプアウト要素が削除アニメーションを開始すると、イベントが発生します。 |
swipeoutDeleted | イベントは、swipeout 要素が DOM から削除される直前に削除アニメーションを完了した後に発生します。 |
swipeoutOverswipeEnter | オーバーワイプが有効になるとイベントが発生する |
swipeoutOverswipeExit | オーバースワイプが無効になると、イベントが発生します。 |
Examples
<Page>
<Navbar title="Swipeout"></Navbar>
<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>
<ListItem
swipeout
title="Swipe left on me please">
<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">
<SwipeoutActions right>
<SwipeoutButton delete confirmText="Are you sure you want to delete this item?">Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
title="I am not removable">
</ListItem>
</List>
<BlockTitle>Swipe to delete without confirm</BlockTitle>
<List>
<ListItem
swipeout
title="Swipe left on me please">
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
swipeout
title="Swipe left on me too">
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
title="I am not removable">
</ListItem>
</List>
<BlockTitle>Swipe for actions</BlockTitle>
<List>
<ListItem
swipeout
title="Swipe left on me please">
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
swipeout
title="Swipe left on me too">
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
swipeout
title="You can't delete me">
<SwipeoutActions right>
<SwipeoutButton onClick={more}>More</SwipeoutButton>
</SwipeoutActions>
</ListItem>
</List>
<BlockTitle>With callback on remove</BlockTitle>
<List>
<ListItem
swipeout
onSwipeoutDeleted={onDeleted}
title="Swipe left on me please">
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
swipeout
onSwipeoutDeleted={onDeleted}
title="Swipe left on me too">
<SwipeoutActions right>
<SwipeoutButton delete>Delete</SwipeoutButton>
</SwipeoutActions>
</ListItem>
<ListItem
title="I am not removable">
</ListItem>
</List>
<BlockTitle>With actions on left side (swipe to right)</BlockTitle>
<List>
<ListItem
swipeout
title="Swipe right on me please">
<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">
<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>
<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>
<script>
import { onMount, onDestroy } from 'svelte';
import {f7, Page, Navbar, Block, BlockTitle, List, ListItem, SwipeoutActions, SwipeoutButton} 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!');
}
onMount(() => {
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',
bold: true,
},
],
],
});
});
onDestroy(() => {
actions.destroy();
});
</script>