Framework7-list-views-swipe-events
Framework7-スワイプアウトイベント
説明
ユーザーがスワイプアウトと対話する方法を検出するには、スワイプアウトイベントを使用できます。 次の表は、Framework7でサポートされるイベントの一覧です-
S.No | Event & Description | Target |
---|---|---|
1 |
swipeout このイベントは、スワイプアウト要素を移動するとトリガーされます。 a |
スワイプアウト要素 <li class = "swipeout"> |
2 |
open スワイプアウトが開始アニメーションを開始するたびに、このイベントがトリガーされます。 a |
スワイプアウト要素 <li class = "swipeout"> |
3 |
opened スワイプアウトが開始アニメーションを完了するたびに、このイベントがトリガーされます。 a |
スワイプアウト要素 <li class = "swipeout"> |
4 |
close スワイプアウト終了アニメーションが開始されるたびに、このイベントがトリガーされます。 a |
スワイプアウト要素 <li class = "swipeout"> |
5 |
closed スワイプアウト終了アニメーションが完了するたびに、このイベントがトリガーされます。 a |
スワイプアウト要素 <li class = "swipeout"> |
6 |
delete スワイプアウト要素が削除アニメーションを開始するたびに、このイベントがトリガーされます。 a |
スワイプアウト要素 <li class = "swipeout"> |
7 |
deleted このイベントは、要素がDOMから削除される直前に削除アニメーションを終了した後にトリガーされます。 a |
スワイプアウト要素 <li class = "swipeout"> |
例
次の例は、Framework7でのスワイプアウトイベントの使用を示しています。
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content = "width = device-width, initial-scale = 1,
maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui"/>
<meta name = "apple-mobile-web-app-capable" content = "yes"/>
<meta name = "apple-mobile-web-app-status-bar-style" content = "black"/>
<title>Swipeout events</title>
<link rel = "stylesheet"
href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css"/>
<link rel = "stylesheet"
href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css"/>
</head>
<body>
<div class = "views">
<div class = "view view-main">
<div class = "pages">
<div data-page = "home" class = "page navbar-fixed">
<div class = "navbar">
<div class = "navbar-inner">
<div class = "left"> </div>
<div class = "center">Swipeout Events</div>
<div class = "right"> </div>
</div>
</div>
<div class = "page-content">
<div class = "list-block">
<ul>
<li class = "swipeout">
<div class = "swipeout-content item-content">
<div class = "item-media"><i class = "icon icon-form-name"></i></div>
<div class = "item-inner">
<div class = "item-title">Item title</div>
<div class = "item-after">Label</div>
</div>
</div>
<div class = "swipeout-actions-right"><a href = "#" class = "action1">Task</a><a href = "#" data-confirm = "Are you sure to delete this item?" class = "swipeout-delete">Delete</a></div>
</li>
<li class = "swipeout">
<div class = "swipeout-content item-content">
<div class = "item-media"><i class = "icon icon-form-name"></i></div>
<div class = "item-inner">
<div class = "item-title">With confirm title</div>
<div class = "item-after"> <span class = "badge">78</span></div>
</div>
</div>
<div class = "swipeout-actions-right"><a href = "#" class = "action1">Task</a><a href = "#" data-confirm = "Are you sure to delete this item?" data-confirm-title = "Delete?" class = "swipeout-delete">Delete</a></div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<script type = "text/javascript"
src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
<script>
var myApp = new Framework7();
var $$ = Dom7;
$$('.swipeout').on('deleted', function () {
myApp.alert('Item removed');
});
$$('.swipeout').on('opened', function () {
myApp.alert('Item opened');
});
$$('.swipeout').on('closed', function () {
myApp.alert('Item closed');
});
</script>
</body>
</html>
出力
上記のコードがどのように機能するかを確認するために次の手順を実行してみましょう-
- 上記のHTMLコードを list_views_swipe_eventsl ファイルとしてサーバーのルートフォルダーに保存します。
- このHTMLファイルをhttp://localhost/list_views_swipe_eventslとして開くと、出力は以下のように表示されます。
- この例では、ユーザーがスワイプアウトイベントを使用してスワイプアウトを操作します。これらのイベントは、スワイプアウト要素を移動、開く、閉じる、削除するとトリガーされます。