本文實(shí)例講述了AngularJS實(shí)現(xiàn)的回到頂部指令功能。分享給大家供大家參考,具體如下:
成都創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站建設(shè)、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的靈丘網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="bootstrap.min.css" rel="external nofollow" > <script src="jquery.min.js"></script> <script src="angular.js"></script> <script src="bootstrap.min.js"></script> <style type="text/css"> #gotoTop { display: none; position: fixed; top: 80%; left: 90%; cursor: pointer; padding: 4px 4px; width: 50px; border: 1px solid #e0e0e0; background: #fff; border-radius: 50px; height: 50px; } #gotoTop.hover { background: #e0e0e0; color: #fff; text-decoration: none; } .arrow { width: 0; height: 0; margin: 0 auto; border: 9px solid transparent; border-bottom-color: #aaa; } .stick { width: 8px; height: 14px; margin: 0 auto; border-radius: 1px; background-color: #aaa; } </style> <script type="text/javascript"> var myapp = angular.module('myapp', []); myapp.directive("goToTop", function() { return { restrict: 'E', replace: true, scope: { minHeight : '@' }, templateUrl : 'tmpl.html', link: function(scope, elem, attrs) { elem.click(function() { jQuery('html,body').animate({scrollTop:0}, 700); }) .hover(function() { jQuery(this).addClass("hover"); }, function() { jQuery(this).removeClass("hover"); }); scope.minHeight = scope.minHeight ? scope.minHeight : 600; jQuery(window).scroll(function() { var s = jQuery(window).scrollTop(); if( s > scope.minHeight) { jQuery("#gotoTop").fadeIn(100); } else { jQuery("#gotoTop").fadeOut(200); }; }); } }; }); </script> </head> <body ng-app="myapp"> <go-to-top min-height="800"></go-to-top> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> <h2>hello world</h2> </body> </html>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站jinyejixie.com,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)站標(biāo)題:AngularJS實(shí)現(xiàn)的回到頂部指令功能實(shí)例-創(chuàng)新互聯(lián)
文章位置:http://jinyejixie.com/article32/cshcsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、企業(yè)建站、響應(yīng)式網(wǎng)站、手機(jī)網(wǎng)站建設(shè)、電子商務(wù)、網(wǎng)站收錄
聲明:本網(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)
猜你還喜歡下面的內(nèi)容