web組件化開發第一天

來源:互聯網
上載者:User

標籤:第一天   cal   doc   viewport   學習   bottom   web   content   組織圖   

 

技術選型

html5 css3 jq

應用的外掛程式

FullPage.js

一、建一個測試頁面,測試靜態功能

<!DOCTYPE html><html><head>    <meta charset="UTF-8"/>    <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">    <title>慕課網2015課程學習情況</title>    <style>        body{            margin:0;            padding:0;        }        .component{            width: 50%;            height:50px;            margin-bottom:20px;            background-color: red;            display: none;        }    </style>    <body>    <!-- 用於驗證 fullpage.js 切換頁面,以及內容組織圖可用,組件能夠進行動畫 -->        <div id="h5">
  <!-- 給每個需要翻頁的頁面添加section類 給定不同的ID -->            <div class="page section" id="page-1">                <div class="component">logo</div>                <div class="component slogan">slogan</div>            </div>            <div class="page section" id="page-2">                <div class="component">logo</div>                <div class="component slogan">slogan</div>            </div>            <div class="page section" id="page-3">                <div class="component">logo</div>                <div class="component slogan">slogan</div>            </div>        </div>    </body></html>

 

 

二、首先載入fullpage.js

   <script type="text/javascript" src="../js/lib/jquery.js"></script>    <script type="text/javascript" src="../js/lib/jquery-ui.min.js"></script>    <script type="text/javascript" src="../js/lib/jquery.fullPage.js"></script>

三、測試功能是否完好。

$(function (){            $(‘#h5‘).fullpage({                    //傳入背景色 sectionsColor 後面接對象。                    ‘sectionsColor‘: [‘#254875‘, ‘#00ff00‘, ‘#245874‘],                    /*                    * 傳入回掉函數 onLeave afterLoad                    * afterLoad                    * 滾動到某一屏後的回呼函數,接收 anchorLink 和 index 兩個參數,                    * anchorLink 是錨連結的名稱,index 是序號,從1開始計算                    * onLeave                    * 滾動前的回呼函數,接收 index、nextIndex 和 direction 3個參數:                    * index 是離開的“頁面”的序號,從1開始計算;                    * nextIndex 是滾動到的“頁面”的序號,從1開始計算;                    * direction 判斷往上滾動還是往下滾動,值是 up 或 down。                    * */                    onLeave: function (index, nextIndex, direction) {                        //讓page執行onLeave事件。                        $(‘#h5‘).find(‘.page‘).eq(index-1).trigger(‘onLeave‘);                    },                    afterLoad: function (anchorLink, index) {                        //讓page執行onLoad事件。                        $(‘#h5‘).find(‘.page‘).eq(index-1).trigger(‘onLoad‘);                    },                });             //給page頁面綁定onLeave事件。            $(‘.page‘).on(‘onLeave‘,function () {                console.log($(this).attr(‘id‘),‘====>‘,‘onleave‘);                //讓component執行onLeave事件。                $(this).find(‘.component‘).trigger(‘onLeave‘);            })            //給page頁面綁定onLoad事件。            $(‘.page‘).on(‘onLoad‘,function () {                console.log($(this).attr(‘id‘),‘====>‘,‘onLoad‘);                //讓component執行onLoad事件。                $(this).find(‘.component‘).trigger(‘onLoad‘);            })            //給component頁面綁定onLoad事件。            $(‘.component‘).on(‘onLoad‘,function () {                $(this).fadeIn();                //防止事件冒泡。迴圈傳播。                return false;            })            //給component頁面綁定onLeave事件。            $(‘.component‘).on(‘onLeave‘,function () {                $(this).fadeOut();                return false;            })        });

 

web組件化開發第一天

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.