欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

iscroll上拉刷新效果怎么實(shí)現(xiàn)

這篇“iscroll上拉刷新效果怎么實(shí)現(xiàn)”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來(lái)看看這篇“iscroll上拉刷新效果怎么實(shí)現(xiàn)”文章吧。

10年的珠暉網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)整合營(yíng)銷(xiāo)推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整珠暉建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“珠暉網(wǎng)站設(shè)計(jì)”,“珠暉網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

iscroll 上拉刷新極簡(jiǎn)入門(mén)案例

  • 注意:只有當(dāng)內(nèi)容超出屏幕區(qū)域才可以上拉刷新呢

演示

使用步驟

1:編寫(xiě)html頁(yè)面,并引入相應(yīng)js文件

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"
        <!--<link rel="stylesheet" href="css/style.css">-->
            <!--引入js文件-->
        <script src="js/jquery.min.js"></script>
        <script src="js/iscroll.js"></script>

        <title>上拉加載更多</title>
    </head>

    <body>
        <!--<header>這是頭部</header>-->
        <!--id為 wrapper 表示這個(gè)div是滑動(dòng)的父窗體-->
        <div id="wrapper">
            <!--scroller 表示這是個(gè)可以滑動(dòng)的控件-->
            <div class="scroller">
                <ul>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                </ul>
                <!--這是上拉刷新的提示信息,會(huì)自動(dòng)隱藏,樣式完全可以自己定義-->
                <div class="more"><i class="pull_icon"></i><span>上拉加載...</span></div>
            </div>
        </div>
        <!--<footer>這是底部</footer>-->
    </body>

</html>

要想這個(gè) div可以被滑動(dòng),對(duì)于 id為 wrapper 的div我們必須加如下的設(shè)置

#wrapper {
                width: 100%;/*必須*/
                position: absolute;/*必須*/
                left: 0;/*必須*/
                top: -1rem;/*必須[如果有頭部,可以設(shè)置為頭部的高度]*/
                bottom: 0rem;/*必須[如果有底部導(dǎo)航欄,這里可以設(shè)置底部導(dǎo)航欄的高度]*/
                overflow: hidden;/*規(guī)定當(dāng)元素內(nèi)部的內(nèi)容超出元素自身的尺寸范圍時(shí)應(yīng)該如何來(lái)處理*/
                z-index: 1;/*層相對(duì)于屏幕縱深方向的順序*/
                background-color: #ccc;/*背景顏色*/
            }

注意上拉刷新的顯示等待信息也是個(gè) html 定義,

<!--這是上拉刷新的提示信息,會(huì)自動(dòng)隱藏,樣式完全可以自己定義-->
                <div class="more"><i class="pull_icon"></i><span>上拉加載...</span></div>

所以我們完全可以定義為我們自己想要的樣式,我定義的如下:這完全是為了好看

<style>#wrapper {
                width:100%;/*必須*/
                position: absolute;/*必須*/
                left:0;/*必須*/
                top:1rem;/*必須[如果有頭部,可以設(shè)置為頭部的高度]*/
                bottom:0rem;/*必須[如果有底部導(dǎo)航欄,這里可以設(shè)置底部導(dǎo)航欄的高度]*/
                overflow: hidden;/*規(guī)定當(dāng)元素內(nèi)部的內(nèi)容超出元素自身的尺寸范圍時(shí)應(yīng)該如何來(lái)處理*/
                z-index:1;/*層相對(duì)于屏幕縱深方向的順序*/
                background-color:#ccc;/*背景顏色*/
            }

            #wrapper li {
                height:10rem;
                line-height:10rem;
                text-align: center;
                border-bottom:1px solid rgba(0, 0, 0, .1);
            }

            .more {
                height:4rem;
                display: flex;
                align-items: center;
                justify-content: center;
                color:#333;
            }

            .pull_icon {
                width:25px;
                height:25px;
                background-image:url('images/pull.png');
                background-repeat: no-repeat;
                background-position: center;
                background-size:25px;
                transition:5s;
            }

            .more span {
                padding-left:5rem;
            }

            .scroller {
                background-color:#fff;
            }

            .more .flip {
                transform:rotate(180deg);
            }

            .loading {
                background-image:url('images/loading.png');
                background-repeat: no-repeat;
                background-position: center;
                background-size:25px;
            }

            .more .loading {
                -webkit-transform:rotate(0deg) translateZ(0);
                -webkit-transition-duration:0;
                -webkit-animation-name: loading;
                -webkit-animation-duration:2s;
                -webkit-animation-iteration-count: infinite;
                -webkit-animation-timing-function: linear;
            }</style>

2: 初始化 iscroll.js

<script>
            var myscroll = new iScroll("wrapper", {
                onScrollMove: function()
                    if(this.y < (this.maxScrollY)) {
                        $('.pull_icon').addClass('flip');
                        $('.pull_icon').removeClass('loading');
                        $('.more span').text('釋放加載...');
                    } else {
                        $('.pull_icon').removeClass('flip loading');
                        $('.more span').text('上拉加載...')
                    }
                },
                //滾動(dòng)到屏幕底部觸發(fā)此事件
                onScrollEnd: function()
                    if($('.pull_icon').hasClass('flip')) {
                        $('.pull_icon').addClass('loading');
                        $('.more span').text('加載中...');
                        //自己的事件(上拉刷新事件)
                        pullUpAction();
                    }

                },
                onRefresh: function()
                    $('.more').removeClass('flip');
                    $('.more span').text('上拉加載...');
                }

            });

            //上拉刷新
            function pullUpAction()
                setTimeout(function()
                    //填充數(shù)據(jù)
                    for(var i = 0; i < 5; i++) {
                        $('.scroller ul').append("<li>一只將死之猿!</li>");
                    }
                    myscroll.refresh();
                }, 1000)
            }
            if($('.scroller').height() < $('#wrapper').height()) {
                $('.more').hide();
                myscroll.destroy();
            }
        </script>

如果你不想了解細(xì)節(jié),只需要關(guān)注 pullUpAction() 方法的實(shí)現(xiàn)即可,在此填充數(shù)據(jù).

至此一個(gè)上拉刷新的功能就完成了.

完整頁(yè)面布局:

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"
        <!--<link rel="stylesheet" href="css/style.css">-->
        <script src="js/jquery.min.js"></script>
        <script src="js/iscroll.js"></script>
        <style>#wrapper {
                width:100%;/*必須*/
                position: absolute;/*必須*/
                left:0;/*必須*/
                top:1rem;/*必須[如果有頭部,可以設(shè)置為頭部的高度]*/
                bottom:0rem;/*必須[如果有底部導(dǎo)航欄,這里可以設(shè)置底部導(dǎo)航欄的高度]*/
                overflow: hidden;/*規(guī)定當(dāng)元素內(nèi)部的內(nèi)容超出元素自身的尺寸范圍時(shí)應(yīng)該如何來(lái)處理*/
                z-index:1;/*層相對(duì)于屏幕縱深方向的順序*/
                background-color:#ccc;/*背景顏色*/
            }

            #wrapper li {
                height:10rem;
                line-height:10rem;
                text-align: center;
                border-bottom:1px solid rgba(0, 0, 0, .1);
            }

            .more {
                height:4rem;
                display: flex;
                align-items: center;
                justify-content: center;
                color:#333;
            }

            .pull_icon {
                width:25px;
                height:25px;
                background-image:url('images/pull.png');
                background-repeat: no-repeat;
                background-position: center;
                background-size:25px;
                transition:5s;
            }

            .more span {
                padding-left:5rem;
            }

            .scroller {
                background-color:#fff;
            }

            .more .flip {
                transform:rotate(180deg);
            }

            .loading {
                background-image:url('images/loading.png');
                background-repeat: no-repeat;
                background-position: center;
                background-size:25px;
            }

            .more .loading {
                -webkit-transform:rotate(0deg) translateZ(0);
                -webkit-transition-duration:0;
                -webkit-animation-name: loading;
                -webkit-animation-duration:2s;
                -webkit-animation-iteration-count: infinite;
                -webkit-animation-timing-function: linear;
            }</style>
        <title>上拉加載更多</title>
    </head>

    <body>
        <!--<header>這是頭部</header>-->
        <!--id為 wrapper 表示這個(gè)div是滑動(dòng)的父窗體-->
        <div id="wrapper">
            <!--scroller 表示這是個(gè)可以滑動(dòng)的控件-->
            <div class="scroller">
                <ul>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                    <li>你就是一個(gè)天才</li>
                </ul>
                <!--這是上拉刷新的提示信息,會(huì)自動(dòng)隱藏,樣式完全可以自己定義-->
                <div class="more"><i class="pull_icon"></i><span>上拉加載...</span></div>
            </div>
        </div>
        <!--<footer>這是底部</footer>-->
        <script>var myscroll = new iScroll("wrapper", {
                onScrollMove: function()
                    if(this.y < (this.maxScrollY)) {
                        $('.pull_icon').addClass('flip');
                        $('.pull_icon').removeClass('loading');
                        $('.more span').text('釋放加載...');
                    } else {
                        $('.pull_icon').removeClass('flip loading');
                        $('.more span').text('上拉加載...')
                    }
                },
                //滾動(dòng)到屏幕底部觸發(fā)此事件
                onScrollEnd: function()
                    if($('.pull_icon').hasClass('flip')) {
                        $('.pull_icon').addClass('loading');
                        $('.more span').text('加載中...');
                        //自己的事件(上拉刷新事件)
                        pullUpAction();
                    }

                },
                onRefresh: function()
                    $('.more').removeClass('flip');
                    $('.more span').text('上拉加載...');
                }

            });

            //上拉刷新
            function pullUpAction()
                setTimeout(function()
                    //填充數(shù)據(jù)
                    for(var i = 0; i < 5; i++) {
                        $('.scroller ul').append("<li>一只將死之猿!</li>");
                    }
                    myscroll.refresh();
                }, 1000)
            }
            if($('.scroller').height() < $('#wrapper').height()) {
                $('.more').hide();
                myscroll.destroy();
            }
        </script>
    </body>

</html>

以上就是關(guān)于“iscroll上拉刷新效果怎么實(shí)現(xiàn)”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

分享題目:iscroll上拉刷新效果怎么實(shí)現(xiàn)
網(wǎng)站路徑:http://chinadenli.net/article24/geocce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)網(wǎng)站導(dǎo)航網(wǎng)站收錄微信公眾號(hào)軟件開(kāi)發(fā)關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)