Giter Club home page Giter Club logo

cxscroll's Introduction

jQuery cxScroll

一款基于jQuery的无缝滚动插件,可自定义外观及调用参数,兼容主流浏览器。

版本:

  • jQuery v1.7+
  • jQuery cxScroll v1.2.2

注意事项:

  1. 内部会自动创建 prev 及 next 切换按钮,也可以在外部直接创建,若外部已创建或设置 prevBtn:false 及 nextBtn:false ,内部将跳过此步骤;
  2. 若(滚动的列表宽度 ≤ 父元素的宽度),则不会自动创建 prev 及 next 切换按钮,也不会自动滚动。

文档:http://code.ciaoca.com/jquery/cxScroll/

示例:http://code.ciaoca.com/jquery/cxScroll/demo/

使用方法

CSS 样式结构

除必要属性设置外,其他样式均可自行设置。

/* 横向滚动基本样式 */
.cxscroll{}
.cxscroll .box{overflow:hidden;width:600px;}
.cxscroll .list{overflow:hidden;width:9999px;}
.cxscroll .list li{float:left;width:200px;height:100px;}
.cxscroll .prev{}
.cxscroll .next{}

/* 纵向滚动基本样式 */
.cxscroll{}
.cxscroll .box{overflow:hidden;height:300px;}
.cxscroll .list{}
.cxscroll .list li{height:100px;}
.cxscroll .prev{}
.cxscroll .next{}

DOM 结构

<div id="element_id" class="cxscroll">
    <div class="box">
        <ul class="list">
            <li></li>
            <li></li>
            ...
            <li></li>
        </ul>
    </div>
    <!-- 控制按钮会自动创建,可省略 -->
    <a class="prev"></a>
    <a class="next"></a>
</div>

调用 cxScroll

$("#element_id").cxScroll();

options 参数说明

名称 默认值 说明
direction 'right' 滚动方向。可设置为:"left", "right", "top", "bottom"
easing 'swing' 缓动方式
step 1 滚动步长
accel 200 手动滚动速度 (ms),点击控制按钮滚动的速度。
speed 800 自动滚动速度 (ms)
time 4000 自动滚动间隔时间 (ms)
auto true 是否自动滚动
hoverLock true 鼠标移入移出锁定。鼠标进入区域内时停止自动轮播,离开后恢复自动轮播(仅在 auto 为 true 时有效)
prevBtn true 是否使用 prev 按钮
nextBtn true 是否使用 next 按钮

API接口

var Api;
$('#element_id').cxScroll(function(api){
  Api = api;
});
// 或者作为第二个参数传入
$('#element_id').cxScroll({
  minus: true,
  plus: true
}, function(api){
  Api = api;
});
名称 说明
play() 开始自动播放
stop() 停止自动播放
prev(speed) 向前滚动。speed 为滚动速度(ms)
next(speed) 向后滚动。speed 为滚动速度(ms)

cxscroll's People

Contributors

ciaoca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cxscroll's Issues

横向滚动超过超过一定数量后会有错误

如:li的width为280px,li里面包含一个img,width是270px.一共是50个li,在滚动到第39个以后,图片就不会在有滚动效果了(后面就是空白了)。
修正方法,是把list样式中的width:9999px修改大一些,比如99999px
qq 20180711092203

csScroll的兼容性

IE下会出现篮色的border,设置图片的border:none就可以了,其他,好像ie下面的兼容性不是很好

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.