Swipeout 事件(Swipeout events)
优质
小牛编辑
129浏览
2023-12-01
描述 (Description)
要检测用户与滑动内容的交互方式,您可以使用swipeout事件。 下表列出了Framework7支持的事件 -
S.No | 活动和描述 | 目标 |
---|---|---|
1 | swipeout 移动swipeout元素时将触发此事件。 | Swipeout元素 |
2 | open 每当swipeout开始打开动画时,都会触发此事件。 | Swipeout元素 |
3 | opened 每当swipeout完成其打开动画时,都会触发此事件。 | Swipeout元素 |
4 | close 每当启动向上滑动关闭动画时,都会触发此事件。 | Swipeout元素 |
5 | closed 每当滑出关闭动画完成时,将触发此事件。 | Swipeout元素 |
6 | delete 每当swipeout元素开始删除动画时,都会触发此事件。 | Swipeout元素 |
7 | deleted 元素在从DOM中删除之前完成其删除动画后将触发此事件。 | Swipeout元素 |
例子 (Example)
以下示例演示了在Framework7中使用swipeout事件 -
<!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>
输出 (Output)
让我们执行以下步骤,看看上面给出的代码是如何工作的 -
将上面给出的HTML代码保存为服务器根文件夹中的list_views_swipe_events.html文件。
以http://localhost/list_views_swipe_events.html打开此HTML文件,输出显示如下。
该示例通过使用swipeout事件提供用户与swipeout的交互,当您移动,打开,关闭和删除swipeout元素时,将触发这些事件。