successanim_list.html 3.17 KB
<!-- 
        作者:dailc
        时间:2017-08-28
        描述: 带成功动画的示例
        虽然目前只有default主题提供了成功动画,但是其实任何主题都是能实现的
        在一些特殊常见下可嫩会用到成功动画(如要求刷新成功后出来一个成功特效)
-->
<!DOCTYPE html>
<html lang="zh-CN">

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <title>base list</title>
        <link rel="stylesheet" href="../../dist/debug/minirefresh.css" />
        <link rel="stylesheet" href="../common/common.css" />

    </head>

    <body>

        <nav class="navbar-header">
            <a class="nav-btn-left" href="../index.html">dashboard</a>
            带成功动画的示例
        </nav>
        <div class="content">

            <div id="minirefresh" class="minirefresh-wrap">
    
                <div class="minirefresh-scroll">
    
                    <ul class="data-list" id="listdata">
    
                    </ul>
                </div>
            </div>
        </div>

        <script type="text/javascript" src="../../dist/debug/minirefresh.js"></script>
        <script type="text/javascript" src="../common/common.js"></script>
        <script>
            var appendTestData = Common.appendTestData,
                // 记录一个最新
                maxDataSize = 30,
                listDom = document.querySelector('#listdata'),
                requestDelayTime = 600;

            var miniRefresh = new MiniRefresh({
                container: '#minirefresh',
                down: {
                    successAnim: {
                        // 下拉刷新结束后是否有成功动画,默认为false,如果想要有成功刷新xxx条数据这种操作,请设为true,并实现对应hook函数
                        isEnable: true,
                        duration: 300
                    },
                    // 可选,刷新成功的提示,当开启successAnim时才有效
                    contentsuccess: '刷新成功',
                    // 可选,刷新失败的提示,错误回调用到,当开启successAnim时才有效
                    contenterror: '刷新失败',
                    callback: function() {
                        setTimeout(function() {
                            // 每次下拉刷新后,上拉的状态会被自动重置
                            appendTestData(listDom, 10, true);
                            miniRefresh.endDownLoading(true, '成功更新10条数据');
                        }, requestDelayTime);
                    }
                },
                up: {
                    isAuto: true,
                    callback: function() {
                        setTimeout(function() {
                            appendTestData(listDom, 10);
                            miniRefresh.endUpLoading(listDom.children.length >= maxDataSize ? true : false);
                        }, requestDelayTime);
                    }
                }
            });
        </script>
    </body>

</html>