zoukankan      html  css  js  c++  java
  • IScroll 判断是否滚动到底部并加载更多数据

        <!DOCTYPE html>
        <html>
         
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
            <title>IScroll 判断是否滚动到底部并加载更多数据</title>
            <style type="text/css">
            body {
                margin: 0;
                overflow: hidden;
            }
         
            .wrapper {
                position: absolute;
                top: 0;
                bottom: 50px;
                right: 0;
                 200px;
                background: #f8f8f9;
            }
         
            .wrapper ul {
                margin: 0;
                padding: 0 10px;
            }
         
            .m-item {
                position: relative;
                height: 100px;
                border: 1px solid green;
                list-style: none
            }
         
            .footer {
                position: absolute;
                bottom: 0;
                left: 0;
                 100%;
                height: 50px;
                background: #444;
            }
            .mCustomScrollBox{overflow: unset;}
            .mCSB_container{overflow: unset;}
            </style>
        </head>
         
        <body>
            <div id="wrapper" class="wrapper">
                <ul id="m-list">
                </ul>
            </div>
            <div class="footer"></div>
            <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
            <script src="https://cdn.bootcss.com/iScroll/5.2.0/iscroll.js"></script>
            
            <script type="text/javascript">
            $(function() {
                var dom = {
                    wrapper: $('#wrapper'),
                    list: $('#m-list')
                };
                var html = '';
                for (var i = 0 ; i < 10; i++) {
                    html += '<li class="m-item js-item">' + i + '</li>'
                }
                dom.list.html(html);    
    
                function scrollEndFn () {
                    if (this.y - 200 < this.maxScrollY && (this.directionY === 1)) {
                        console.log('滚动到底部');
                        var html = '';
                        for (var i = 0 ; i < 10; i++) {
                            html += '<li class="m-item js-item">' + i + '</li>'
                        }
                        dom.list.append(html);  
                        if (myScroll) {
                            myScroll.refresh();
                        }                
                    }
                }            
                myScroll = new IScroll('#wrapper', { 
                    click: true,        //支持点击
                    scrollbars: true,   //显示滚轮
                    mouseWheel: true,   //鼠标滚轮可以滚动
                    interactiveScrollbars:true,  //滚动条可以拖动
                    preventDefault: false, //禁止阻止浏览器默认行为,可以选择文字             
                });
                myScroll.on('scrollEnd', scrollEndFn);                
            });
            </script>
        </body>
         
        </html>
  • 相关阅读:
    EOS 数据库RAM使用量的计算
    EOS require_auth函数
    EOS测试链智能合约部署调用
    安装EOS合约工具eosio.cdt
    Linux Ubuntu下搭建Flutter桌面环境
    VMware虚拟机与物理机共享文件的方法总结
    虚拟机macOS Mojave10.14安装XCode10.1
    VMware14 安装 macOS Mojave教程
    VMware 14安装OS X10.11
    Mac OS虚拟机安装VMware Tools的方法
  • 原文地址:https://www.cnblogs.com/xutongbao/p/9924818.html
Copyright © 2011-2022 走看看