JS滑鼠滾動外掛程式scrollpath使用介紹

來源:互聯網
上載者:User

標籤:http   使用   io   art   ar   cti   html   line   

JS滑鼠滾動外掛程式scrollpath:在這個外掛程式中首先要引人的JS是jQuery,因為後面的JS都是基於它的。再者需要引入的是jquery.scrollpath.js、scrollpath.css還有你自己的JS和CSS。

prefixfree.min.js和jquery.easing.js可以根據實際情況自己選擇。

首先編寫好HTML,在一個絕對位置塊中分別布好每個塊的位置

 

然後開始根據位置用JS畫路徑。

定義路徑:

$.fn.scrollPath("getPath")

.moveTo(x, y, {name: "start"}) // x,y可以理解為定義x軸,y軸的起始點

 

.lineTo(0, 800, {name: "d1"}) //移動線條,向右向下為正,反之為負,向下直線畫路徑到名字為d1的點

.lineTo(800, 800,  {

                    callback: function() {

                           alert("到達某一個點後可以定義回呼函數")

                    },name: "d2"}

             )

// 以x = 200,y = 200為圓心,半徑是400,畫圓弧,水平向右是0度,Math.PI表示180度,-Math.PI/4表示順時針旋轉90度

.rotate(2*Math.PI, {

                    name: "rotations-rotated"

             })

.arc(400, 0, 400, 0, -Math.PI, true, {name: "d4"});

 

添加路徑

$(".wrapper").scrollPath({drawPath: true, wrapAround: true});

顯示路徑

$(".sp-canvas").show()

繪製路徑,可定義速度:

$.fn.scrollPath("scrollTo", target, 1000, "easeInOutSine");

 

繪製的路徑效果是這樣的http://demo.qpdiy.com/hxw/scrollpath-master/hxw.html

稍微複雜點的路徑可以看http://www.jiawin.com/jquery-scroll-path/

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.