利用TweenMax針對HTML頁面製作動畫 – jQuery Mobile篇
在Dreamweaver5.5之後多了一個jQuery Mobile面板,主要是利用jQuery來製作一些行動裝置的元素,接下來這篇文章就利用Dreamweaver提供的幾項元素加上TweenMax來製作手機動畫頁面。
因為這篇文章應用到的動畫功能,依舊和前兩篇差不多,所以就直接看範例吧!首先,第一個範例是利用「jQuery 翻轉切換開關」來控制動畫的播放,除了可以從前面的連結看到這個範例之外,也因為這是特別針對行動裝置所設計的案例,大家也可以在手機輸入「goo.gl/LofiK」網址來觀賞,下面是本範例整個網頁的程式碼:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalabke=no, width=device-width" /> <title>貓咪欣賞</title> <link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"> <script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script> <script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script> <script src="src/minified/TweenMax.min.js"></script> <style type="text/css"> * { margin: 0px; padding: 0px; } #photo { text-align: center; } #selector { text-align: center; width: 50%; margin-left: auto; margin-right: auto; } </style> <script language="javascript"> var playNo = 1; /* 定義目前播放張數變數 */ function photoPlay() { var controler = document.getElementById("flipswitch"); if (controler.options[controler.selectedIndex].value == "on") { clock = setInterval(timer, 5000); } else { clearInterval(clock); } /* 設定每五秒執行timer函數 */ function timer() { var pic = document.getElementById("photo"); /* 利用pic紀錄畫面中ID為photo的元素 */ playNo++; /* 增加張數 */ if (playNo > 19) { playNo = 1; } /* 設定超過圖片張數後從頭播放 */ TweenMax.to(pic, 1, { css: { alpha: 0 }, ease: Expo.easeIn, onComplete: function () { pic.innerHTML = "<img src=photo/photo" + playNo + ".jpg width=300 height=200>"; TweenMax.to(pic, 1, { css: { alpha: 1 }, ease: Expo.easeOut }); } }); } } </script> </head> <body onLoad="photoPlay()"> <div data-role="page" id="page"> <div data-role="header"> <h1>貓咪欣賞</h1> </div> <div data-role="content"> <div id="photo"><img src="photo/photo1.jpg"></div> <div data-role="fieldcontain" id="selector"> <select name="flipswitch" id="flipswitch" onChange="photoPlay()" data-role="slider"> <option value="off">關閉</option> <option value="on" selected>開啟</option> </select> </div> </div> <div data-role="footer"> <h4>©2012 Copyright Stanley Ma Cloud Research.</h4> </div> </div> </body> </html>
接下來的第二個範例在程式上面會比較複雜,因為想要加強上一個範例的互動性,所以在同樣的範例上面增加「上一張」、「下一張」與「播放控制」的功能,可在手機輸入「goo.gl/GyAVt」網址觀賞,如果你仔細看的話,會發現這個範例中呼叫網頁元素的語法有改變,其實既然是利用jQuery來製作,本來就可以利用jQuery所提供呼叫網頁元素的指令來製作會比較方便,總之是因為有了下面這行語法,才可以利用這種方式來呼叫的喔!
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
下面是本範例整個網頁的程式碼:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalabke=no, width=device-width" /> <title>貓咪欣賞</title> <style type="text/css"> * { margin: 0px; padding: 0px; } #photo { text-align: center; } #selector { text-align: center; width: 50%; margin-left: auto; margin-right: auto; } #count { text-align: center; width: 50%; margin-left: auto; margin-right: auto; font-size: 12px; } </style> <link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"> <script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script> <script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script> <script src="src/minified/TweenMax.min.js"></script> <script language="javascript"> var playing = 1; /* 偵測目前是否為播放中的變數(1為播放0為暫停) */ var playNo = 1; /* 定義目前播放張數變數 */ /* 執行計時器 */ function photoPlay() { clock = setInterval(timer, 5000); } /* 計時執行函數 */ function timer() { playNo++; /* 增加張數 */ checkPlayNo() /* 呼叫檢查張數是否有誤的函數 */ photoSlide(); /* 呼叫動畫切換照片的函數 */ } /* 動畫切換照片的函數 */ function photoSlide() { var pic = $("#photo"); /* 利用pic紀錄畫面中ID為photo的元素 */ TweenMax.to(pic, 0.5, { css: { alpha: 0 }, ease: Expo.easeIn, onComplete: function () { pic.html("<img src=photo/photo" + playNo + ".jpg width=300 height=200>"); TweenMax.to(pic, 1, { css: { alpha: 1 }, ease: Expo.easeOut }); } }); $("#count").html(playNo + " / 19"); /* 更換顯示張數的文字 */ } /* 檢查張數是否有誤的函數 */ function checkPlayNo() { if (playNo > 19) { playNo = 1; } else if (playNo < 1) { playNo = 19; } } /* 前往上一張的函數 */ function prevFn() { clearInterval(clock); playNo--; checkPlayNo() photoSlide(); photoPlay(); } /* 前往下一張的函數 */ function nextFn() { clearInterval(clock); playNo++; checkPlayNo() photoSlide(); photoPlay(); } /* 播放控制函數 */ function controlFn() { if (playing == 1) { playing = 0; $("#controlBtn").html("播放") clearInterval(clock); } else if (playing == 0) { playing = 1; $("#controlBtn").html("暫停") clock = setInterval(timer, 5000); } } </script> </head> <body onLoad="photoPlay()"> <div data-role="page" id="page"> <div data-role="header"> <h1>貓咪欣賞</h1> </div> <div data-role="content"> <div id="photo"><img src="photo/photo1.jpg"></div> <div data-role="controlgroup" data-type="horizontal" id="selector"><a href="#" data-role="button" id="prevBtn" onClick="prevFn()">上一張</a><a href="#" data-role="button" onClick="controlFn()"><label id="controlBtn">暫停</label></a><a href="#" data-role="button" onClick="nextFn()">下一張</a></div> <div id="count">1 / 19</div> </div> <div data-role="footer"> <h4>©2012 Copyright Stanley Ma Cloud Research.</h4> </div> </div> </body> </html>
希望大家看過這幾篇「利用TweenMax針對HTML頁面製作動畫」的範例之後,可以更順利的創作出自己的網頁。
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали срочный ремонт iphone se 2020, можете посмотреть на сайте: ремонт iphone se 2020 в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
best canadian online pharmacy reviews https://mexicaneasypharm.shop/# best online pharmacies in mexico
india pharmacy
IndianCertPharm Indian Cert Pharm Indian Cert Pharm
https://mexicaneasypharm.com/# Mexican Easy Pharm
pharmacy rx world canada
cross border pharmacy canada https://mexicaneasypharm.com/# Mexican Easy Pharm
best india pharmacy
canadian drugstore online: CanadianMdPharm – canada drugs
Mexican Easy Pharm: mexico drug stores pharmacies – Mexican Easy Pharm
Indian Cert Pharm: Online pharmacy – IndianCertPharm
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали ремонт iphone xs max, можете посмотреть на сайте: ремонт iphone xs max адреса
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
Aw, this was an incredibly nice post. Spending some time and actual effort to produce a very good article… but what can I say… I hesitate a lot and don’t seem to get nearly anything done.
What Is Best Brand Of Refrigerator? History Of Best
Brand Of Refrigerator What is best brand of Refrigerator
canada drugstore pharmacy rx https://mexicaneasypharm.com/# Mexican Easy Pharm
best online pharmacy india
canadian pharmacy king reviews https://indiancertpharm.com/# Indian pharmacy international shipping
buy prescription drugs from india
Mexican Easy Pharm: Mexican Easy Pharm – mexico drug stores pharmacies
The Complete Guide To Best Fridge refrigerators best brands
canadian pharmacy antibiotics: Canadian Md Pharm – northwest canadian pharmacy
вывод из запоя на дому нижний вывод из запоя на дому нижний .
Indian Cert Pharm: indian pharmacy online – indian pharmacy
Mexican Easy Pharm: medication from mexico pharmacy – Mexican Easy Pharm
https://canadianmdpharm.online/# canadian pharmacy meds review
canada pharmacy reviews
Hello I am so glad I found your webpage, I really found you by mistake, while I was browsing on Askjeeve for something else, Anyhow I am here now and would just like to say kudos for a remarkable post and a all round exciting blog (I also love the theme/design), I don’t have time to browse it all at the minute but I have saved it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the great jo.
https://tm-marmelad.com.ua/perevagi-bi-led-linz-dlya-vashogo-avtomobilya-chomu-varto-pereyti-na-novu-tehnologiyu
https://mexicaneasypharm.shop/# п»їbest mexican online pharmacies
is canadian pharmacy legit
He then moved to his father’s residence in Eaton County.
Where Will Integrated Fridge Frezer One Year From Now?
fridge freezer in Uk
рейтинги производительности процессоров рейтинги производительности процессоров .
Could be elevated to any measurement with out losing high quality.
Bet Zula, canl? bahis konusunda essiz deneyimler sunar. Fenerbahce Galatasaray derbisi icin en h?zl? sekilde kazanma sans?n?z? art?rabilirsiniz.
Betzula’n?n yuksek guvenlik onlemleri, profesyonel hizmet garantisi verir. Bet Zula sosyal medya hesaplar?yla ozel promosyonlardan haberdar olabilirsiniz.
en onemli spor etkinliklerinin en iyi oranlarla kazanc saglayabilirsiniz.
Ayr?ca, platformun en yeni versiyonu, kesintisiz bahis deneyimi sunar. Ozel olarak, fenerbahce galatasaray betzula, tum bahis severler icin en iyi cozum.
Betzula, spor bahislerinden canl? casino oyunlar?na kadar en iyi deneyimi yasatmay? amaclar. favori tak?m?n?z?n galibiyetini kutlamak icin hemen Betzula’ya kat?l?n!
371212+
best canadian pharmacy canadian pharmacy reviews legit canadian pharmacy
canada pharmacy online https://indiancertpharm.shop/# Indian Cert Pharm
india pharmacy
My spouse and I absolutely love your blog and find nearly all of your post’s to be just what I’m looking for. can you offer guest writers to write content for you? I wouldn’t mind composing a post or elaborating on a few of the subjects you write related to here. Again, awesome weblog!
https://510.com.ua/bi-led-linzy-dlya-avto-yak-obraty-idealnyy-variant