JavaScript touch control slider

來源:互聯網
上載者:User
Download v0.95 (3KB minified and gzipped).Actively supports these browsers: IE6+, Firefox 3+, Safari 5 (mobile Safari 4), Chrome 15, Opera 10+. Need jQuery 1.6+.Source code on GitHub.TweetHow to useTouchSlider depends on jQuery. Include both in your header:<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script src="jquery.touchslider.min.js"></script><script>jQuery(function($) {    $(".touchslider").touchSlider({/*options*/});});</script>In your html do something like:<div class="touchslider">    <div class="touchslider-viewport" style="width:500px;overflow:hidden"><div>        <div class="touchslider-item"><!-- your html content --></div>        <div class="touchslider-item"></div>        ...    </div></div>    <div>        <span class="touchslider-prev">←</span>        <span class="touchslider-nav-item touchslider-nav-item-current">1</span>        <span class="touchslider-nav-item">2</span>        ...        <span class="touchslider-next">→</span>    </div></div>JavaScript options:container: this,duration: 350, // the speed of the sliding animation in millisecondsdelay: 3000, // initial auto-scrolling delay for each loopmargin: 5, // borders size. The margin is set in pixels.mouseTouch: true,namespace: "touchslider",next: ".touchslider-next", // jQuery object for the elements to which a "scroll forwards" action should be bound.pagination: ".touchslider-nav-item",currentClass: "touchslider-nav-item-current", // class name for current pagination item.prev: ".touchslider-prev", // jQuery object for the elements to which a "scroll backwards" action should be bound.scroller: viewport.children(),autoplay: false, // whether to move from image to image automaticallyviewport: ".touchslider-viewport"Note: be sure not to include a "," after the last line or you'll get an error in Internet Explorer.To manually start and stop the slider you can use the following code:$(".touchslider").data("touchslider").stop(); // stop the slider$(".touchslider").data("touchslider").start(); // start the slider
相關文章

聯繫我們

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