本文實例為大家分享了基於jQuery實現的手機端圖片滑塊動畫源碼,供大家參考,具體內容如下
效果圖:
在線預覽 下載地址
實例代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>適應手機端的jQuery圖片滑塊動畫DEMO演示</title> <link rel="stylesheet" href="/api/jq/5733e37626dcb/css/style.css" /> <script src="/api/jq/5733e37626dcb/js/islider.js"></script> <script src="/api/jq/5733e37626dcb/js/plugins/islider_desktop.js"></script> </head> <body> <!-- 代碼 開始 --> <!--<h4 style="text-align: center">animateType參數中設置,目前支持default, rotate, flip 和 depth, 點擊按鈕看效果</h4>--> <div id="iSlider-effect-wrapper"> <div id="animation-effect" class="iSlider-effect"></div> </div> <div id="menu-select"> <span class="on">default</span> <span>rotate</span> <span>flip</span> <span>depth</span> </div> <h4 style="text-align: center">垂直輪播</h4> <div id="vertical-slide" class="iSlider-effect"></div> <h4 style="text-align: center">不循環模式(最始及最末圖片滑動會有衰減效果)</h4> <div id="non-looping" class="iSlider-effect"></div> <h4 style="text-align: center">DOM</h4> <div id="dom-effect" class="iSlider-effect"></div> <script> var picList = [ { width: 150, height: 207, content: "/api/jq/5733e37626dcb/images/1.jpg", }, { width: 150, height: 207, content: "/api/jq/5733e37626dcb/images/2.jpg", }, { width: 150, height: 207, content: "/api/jq/5733e37626dcb/images/3.jpg", }, { width: 150, height: 207, content:"/api/jq/5733e37626dcb/images/5.jpg" }, { width: 150, height: 207, content:"/api/jq/5733e37626dcb/images/6.jpg" }, { width: 300, height: 414, content:"/api/jq/5733e37626dcb/images/7.jpg" }, { width: 150, height: 207, content:"/api/jq/5733e37626dcb/images/8.jpg" }, { width: 150, height: 207, content:"/api/jq/5733e37626dcb/images/9.jpg" } ]; var domList = [ { 'height' : '100%', 'width' : '100%', 'content' : '<div><h1>Home</h1><h2>This is home page</h2><p>home is pretty awsome</p><div>' },{ 'height' : '100%', 'width' : '100%', 'content' : '<div><h1>Page1</h1><h2>This is page1</h2><p>page1 is pretty awsome</p><div>' },{ 'height' : '100%', 'width' : '100%', 'content' : '<div><h1>Page2</h1><h2>This is Page2</h2><p>Page2 is pretty awsome</p><div>' },{ 'height' : '100%', 'width' : '100%', 'content' : '<div><h1>Page3</h1><h2>This is page3</h2><p>page3 is pretty awsome</p><div>' } ]; //all animation effect var islider1 = new iSlider({ data: picList, dom: document.getElementById("animation-effect"), duration: 2000, animateType: 'default', isAutoplay: true, isLooping: true, // isVertical: true, 是否垂直滾動 }); islider1.bindMouse(); //vertical slide var islider2 = new iSlider({ data: picList, dom: document.getElementById("vertical-slide"), duration: 2000, animateType: 'default', isVertical: true, isAutoplay: true, isLooping: true, }); islider2.bindMouse(); //不循環 不自動播放 var islider3 = new iSlider({ data: picList, dom: document.getElementById("non-looping"), animateType: 'default', }); islider3.bindMouse(); //滾動dom var islider4 = new iSlider({ data: domList, dom: document.getElementById("dom-effect"), type: 'dom', animateType: 'default', isAutoplay: true, isLooping: true, }); islider4.bindMouse(); var menu = document.getElementById('menu-select').children; function clickMenuActive(target) { for (var i = 0; i < menu.length; i++) { menu[i].className = ''; } target.className = 'on'; } menu[0].onclick = function() { clickMenuActive(this); islider1._opts.animateType = this.innerHTML; islider1.reset(); }; menu[1].onclick = function() { clickMenuActive(this); islider1._opts.animateType = this.innerHTML; islider1.reset(); }; menu[2].onclick = function() { clickMenuActive(this); islider1._opts.animateType = this.innerHTML; islider1.reset(); }; menu[3].onclick = function() { clickMenuActive(this); islider1._opts.animateType = this.innerHTML; islider1.reset(); }; </script> <!-- 代碼 結束 --> </body> </html>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持。