Code Monkey home page Code Monkey logo

scrollerjs's Introduction

scroller

A number scroller module to be embeded in your web apps.

It's easy to set up

  1. Include the scroller.js into your WEB page with <script type="text/javascript" src="scroller.js"></script>

  2. Create a Scroller instance by callying Scroller.getNewInstance(props) var scroller=Scroller.getNewInstance({ direction:Scroller.DIRECTION.UP, interval:3000, width:200, amount:80, separatorType:Scroller.SEPARATOR.THOUSAND, separator:",", textAlign:"right" });

    --direction : Scroll direction, currently supported direction is UP. Default is UP
    --interval : The time interval to scroll from start to end number in milliseconds. Default is 5 seconds
    --width : The scroller panel width in px. Default is 400px
    --amount : The amount of px to scroll for each number,e.g 0->1,1->2,2->3......Default is 250px
    --separatorType : The separatorType to be used, default is NONE. Possible values are Scroller.SEPARATOR.[NONE|THOUSAND|TIME]
    --separator : The seperator symbol,e.g ",". Default is no separator
    --textAlign : The text alignment on the scroller. It is equivalent to the CSS text-align property. Default is center aligned
    --forceFallback : Force to use DOM animation instead of CSS transition. Default value is false.
    You can omit one or all the properties above. The default value is used if the property is not specified

  3. Append the scroller to the target element to display the scroller. Call scroller.appendTo(target);

  4. Start the scroller by calling scroller.start(number); Here number is the initial number to start, e.g 100

  5. Scroll to the number you want by calling scroller.scrollTo(number);

You can modify the style of the scroller panel by modifying the scroller.css file. The class .scroller-span is the the panel for each individual digit. More classes will be added.

Demo pages

Demo site

Websites which use this module

PixelsTech : http://www.pixelstech.net

Why this?

1. The non compressed version is only 12KB and the minitified version is ONLY 7KB. This means you will spend less on getting more 2. It is cross browser compatible. It has been tested on Chrome 42.0, Firefox 37.0.2, IE 11, Safari 5.1.7, Opera 29.0. 3. It has no dependency. It doesn't any other JS framework to work. 4. More...(Waiting for you to make itt.)

We welcome pull requests to improve its performance and benefit more people.

scrollerjs's People

Contributors

sonic0002 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  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  avatar  avatar  avatar

scrollerjs's Issues

本插件以时钟方式显示,当超过0点时,滚动会出现异常

这个问题发生在最新版本的scrollerJs中,以时钟方式显示。以变化最为频繁的秒数为例,正常情况下,应该是每次向上更新显示一个数字。但在每天0点之后,其每次更新会滚动多个数字。

插件实例配置如下:
width:200,
amount:40,
interval:600,
separatorType:Scroller.SEPARATOR.TIME,
separator:":"

通过阅读源码+debug查明,问题根源在ScrollerImpl.prototype.refresh方法。

问题出现过程大致还原如下:

在23:59:59即将切换至00:00:00时,ScrollerImpl.prototype.scrollTo中的
this.props._mode=(this.beginNum>this.endNum)?Scroller.MODE.COUNTDOWN:Scroller.MODE.COUNTUP;
语句认为this.beginNum > this.endNum,即'235959' > '000000'。这时会将this.props._mode设置为Scroller.MODE.COUNTDOWN,即1(之前是默认值Scroller.MODE.COUNTUP,即0),随后调用this.refresh()。

ScrollerImpl.prototype.refresh中:

if(that.props._mode){
    that.scrollPanelArray[i].setMode(that.props._mode);
}

that.props._mode为1时会执行setMode方法。但在之后的秒数更新中,scrollTo方法会将this.props._mode变回Scroller.MODE.COUNTUP,但因为其值为0,故后续的setMode方法不会被执行,因此滚动方向就被永久改变为Scroller.MODE.COUNTDOWN了。

解决方法:
ScrollerImpl.prototype.refresh中的if判断条件改为that.props._mode !== undefined即可。

还请作者尽快修复此bug,谢谢!顺祝工作顺利~~

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.