一款基於jQuery的支援滑鼠拖拽滑動焦點圖

來源:互聯網
上載者:User

標籤:

記得之前我們分享過一款jQuery全屏廣告圖片焦點圖,圖片轉場效果還不錯。今天我們要分享另外一款jQuery焦點圖外掛程式,它的特點是支援滑鼠拖拽滑動,所以在行動裝置上使用更加方便,你只要用手指滑動螢幕即可切換圖片。

線上預覽   源碼下載

實現的代碼。

html代碼:

 <div class="main_visual">        <div class="flicking_con">            <a class="on" href="#@">1</a> <a href="#@">2</a> <a href="#@">3</a> <a href="#@">4</a>        </div>        <div class="main_image">            <ul>                <li>                    <img src="images/20141206093912_0947.jpg"></li>                <li>                    <img src="images/20141206093851_5791.jpg"></li>                <li>                    <img src="images/20141206092732_4208.jpg"></li>                <li>                    <img src="images/20141206093851_5791.jpg"></li>            </ul>        </div>        <script>            $(".main_image img").each(function () {                var ww = $(".main_image").width();                var w = $(this).width();                var ml = Math.round((parseInt(ww) - parseInt(w)) / 2);                $(this).css({ marginLeft: ml + "px" })            })        </script>    </div>

js代碼:

 $(document).ready(function () {            $(".main_visual").hover(function () {                $("#btn_prev,#btn_next").fadeIn()            }, function () {                $("#btn_prev,#btn_next").fadeOut()            });            $dragBln = false;            $(".main_image").touchSlider({                flexible: true,                speed: 200,                btn_prev: $("#btn_prev"),                btn_next: $("#btn_next"),                paging: $(".flicking_con a"),                counter: function (e) {                    $(".flicking_con a").removeClass("on").eq(e.current - 1).addClass("on");                }            });            $(".main_image").bind("mousedown", function () {                $dragBln = false;            });            $(".main_image").bind("dragstart", function () {                $dragBln = true;            });            $(".main_image a").click(function () {                if ($dragBln) {                    return false;                }            });            timer = setInterval(function () {                $("#btn_next").click();            }, 5000);            $(".main_visual").hover(function () {                clearInterval(timer);            }, function () {                timer = setInterval(function () {                    $("#btn_next").click();                }, 5000);            });            $(".main_image").bind("touchstart", function () {                clearInterval(timer);            }).bind("touchend", function () {                timer = setInterval(function () {                    $("#btn_next").click();                }, 5000);            });        });

via:http://www.w2bc.com/Article/17889

一款基於jQuery的支援滑鼠拖拽滑動焦點圖

聯繫我們

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