Giter Site home page Giter Site logo

odometer's Introduction

优化数字滚动插件自动补零问题

基本使用

删除默认初始化代码,需要自己手动初始化渲染DOM结构,需要添加初始化方法:

const odometerOptions = {
  selector: '.odometer1',
  format: '(,ddd).ddd',
  numberLength: 6,
  duration: 500,
};
Odometer.init(odometerOptions)
odometer.innerHTML = 456.324

或者这样使用

const odometerOptions = {
  format: '(,ddd).ddd',
  numberLength: 6,
  duration: 500,
};
new Odometer({
  el: document.getElementById('odometer'),
  ...odometerOptions
})
odometer.innerHTML = 456.324

新增配置项

numberLength

可以通过numberLength配置项显示的位数,默认为12位数

new Odometer({
  el: dom,
  theme: 'default',
  duration: 80,
  format: '(,ddd)',
  numberLength:12
});

zeroFlag

是否区分补零和数字中的零

new Odometer({
  el: dom,
  theme: 'default',
  duration: 80,
  zeroFlag: true,
  format: '(,ddd)',
  numberLength: 12
});

其它剩余配置用法https://github.com/HubSpot/odometer 保持一致

具体测试效果可以打开test文件中的demo.html查看结果

odometer's People

Contributors

wqzwh avatar

Watchers

James Cloos avatar

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.