Code Monkey home page Code Monkey logo

react-odometerjs's People

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

Watchers

 avatar

react-odometerjs's Issues

Duration always default

Hello!

Everything good, except duration.

<Odometer format="( ddd).dd" duration={ 20000 } value={ odometerNumber } />

Regardless if I put 20000 or 500, always takes 3000ms for the animation.
Need fix or I miss something?

Move the underlying Odometer.js to a maintained fork

Moving the underlying library over to another fork or integrating it entirely will allow us to fix its flaws and improve the component drastically.

I don't know of a well maintained fork, but taking one from the many pull requests on the original repo would be a good place to start.

I found this one which makes displaying currency with odometer.js more effective.

8 symbol in value

2018-02-08 15 01 51

Why he's add symbol 8?

Oh, i find it
2018-02-08 15 15 29
it's from to odometer.js

in version 1.0.1 all fine, bun version 2.0.0 has bug
Thats it, i can't use it, cuz react 15.6.2 deps, but i use 16.2.0

React-Odometer.js Doesn't Work with Next.js v12

Next.js v12 has recently came out, however, it appears that the newest version completely broke this package.

In development mode we're receiving the following error:

transitionCheckStyles = document.createElement('div').style;
  ^

ReferenceError: document is not defined

This error also prevents launching website in production mode.

I have confirmed this issue doesn't exist with Next.js v11.

unable to resolve dependency tree

This is not supported by the new React Version 17.0.2

Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"17.0.2" from the root project
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.3.0" from [email protected]
npm ERR! node_modules/react-odometerjs
npm ERR!   react-odometerjs@"*" from the root project

Incompatibility with React 16.0.0-beta.5 ?

Hei,

I tried your plugin using React 16.0.0-beta.5 and it crashes with the error TypeError: Cannot read property 'odometer' of null

Perhaps, react-dom will need to be updated when react 16 will be released.

new Odometer
V:/Git/canard/node_modules/odometer/odometer.js:133
  130 |   _this = this;
  131 | this.options = options;
  132 | this.el = this.options.el;
> 133 | if (this.el.odometer != null) {
  134 |   return this.el.odometer;
  135 | }
  136 | this.el.odometer = this;

ReactOdometer.componentDidMount
V:/Git/canard/node_modules/react-odometerjs/dist/index.js:43
  40 | _createClass(ReactOdometer, [{
  41 |   key: 'componentDidMount',
  42 |   value: function componentDidMount() {
> 43 |     this.odometer = new _odometer2.default(_extends({
  44 |       el: _reactDom2.default.findDOMNode(this),
  45 |       value: this.props.value
  46 |     }, this.props.options));

Breaks Gatsby build

$ gatsby build
...
failed Building static HTML for pages - 1.838s

 ERROR #95312 

"document" is not available during server side rendering.

See our docs page for more info on this error: https://gatsby.dev/debug-html


  31 |   TRANSITION_END_EVENTS = 'transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd';
  32 |
> 33 |   transitionCheckStyles = document.createElement('div').style;
     | ^
  34 |
  35 |   TRANSITION_SUPPORT = (transitionCheckStyles.transition != null) || (transitionCheckStyles.webkitTransition != null) ||
(transitionCheckStyles.mozTransition != null) || (transitionCheckStyles.oTransition != null);
  36 |


  WebpackError: ReferenceError: document is not defined
  
  - odometer.js:33 
    node_modules/odometer/odometer.js:33:1
  
  - odometer.js:653 
    node_modules/odometer/odometer.js:653:2
  
  - index.js:15 
    node_modules/react-odometerjs/dist/index.js:15:17

Does not work with Next.js

  • Example code snippet provided is inaccurate and does not work
  • Value immediately goes from 0 to x value

Nextjs Dyncamic import animation doesn't work?

Hi there, I'm using react-odometerjs in Nextjs.
As suggested by the doc, I import it with dynamic import but I this way the number don't animate when change.
Maybe is something else but if I import it without dynamic import, I can see the number animate just before the next render when I get the error "document not defined".

Anyone else having this issue?

Can't override the styles

How can I override the styles for digits? Also, is there any way to keep the animation going so like if it reaches maximum, it can restart from minimum again?

Can't use the lib with Typescript

Hello friend. I´m trying to use the lib with .tsx with Next.js but it´s not working.

Could not find a declaration file for module 'react-odometerjs'. '.../node_modules/react-odometerjs/dist/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-odometerjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-odometerjs';`ts(7016)

Any tip?

Thank you :)

import dynamic from 'next/dynamic';

const Odometer = dynamic(import('react-odometerjs'), {
  ssr: false,
  loading: () => 0,
});

import { Container, Content, Title, Item } from './styles';

export function OurNumbers() {
  return (
    <Container>
      <Title>Números</Title>
      <Content>
        <Item>
          <Odometer value={1234} format="(.ddd),dd" />
        </Item>
        <Item>
          <Odometer value={1234} format="(.ddd),dd" />
        </Item>
        <Item>
          <Odometer value={1234} format="(.ddd),dd" />
        </Item>
      </Content>
    </Container>
  );
}

Unexpected behavior using create-react-app

Hi, very much looking forward to using this library. But I tried just a demo in create-react-app and the output did not match what I was expecting. The value I entered is 1234 and the output I received was 81,828384!

screen shot 2017-07-26 at 12 00 40 pm

My App.js file in a fresh create-react-app. I copied the options from the odometer docs. Even without it, the value is way off.

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Odometer from 'react-odometerjs';

class App extends Component {
  render() {
    return (
      <div className="App">
        <Odometer
          value={1234}
          format="(,ddd).dd"
          options={{
            auto: false, // Don't automatically initialize everything with class 'odometer'
            selector: '.my-numbers', // Change the selector used to automatically find things to be animated
            format: '(,ddd).dd', // Change how digit groups are formatted, and how many digits are shown after the decimal point
            duration: 3000, // Change how long the javascript expects the CSS animation to take
            theme: 'car', // Specify the theme (if you have more than one theme css file on the page)
            animation: 'count'
          }}
        />
      </div>
    );
  }
}

export default App;

Any idea what's going on here? I'm lost.

Thanks!

Rich

document is not defined !!

When trying to render your component. It's showing the error in odometer js file that document is not defined !!

format not working as expected - or perhaps I am dumb

I am using version 2.1.0 with react 16.4.1 (If this helps to identify, I can also specify other packages in use).

I am trying to add an odometer to our page reflecting money. I can't seem to get the '$'-sign in front of the number(This is not major, and no biggie if it can't really be done).

My main issue is when I attempt to use format (,ddd).dd, I am still not getting the last d when it is 0.

this.setState({ theMoney: 17.60 });

...

<Odometer value={this.state.theMoney} duration={1000} format='(,ddd).dd'/>

Above results in the odometer still showing "17.6"

I have attempted converting theMoney to a string but, as expected, it is converting back to a number under the hood, so the last 0 still gets lost.

Is this a known issue, or am I just doing something wrong? I admit I am in an unfamiliar codebase, and have not used odometer before, so it is possible I am just doing something dumb, or missed something in documentation somewhere.

Thanks in advance for any assistance.

document is not defined

transitionCheckStyles = document.createElement('div').style;
   ^
 
 ReferenceError: document is not defined
     at Object.<anonymous> (/home/xxx/node_modules/odometer/odometer.js:33:3)
     at Object.<anonymous> (/home/xxx/node_modules/odometer/odometer.js:653:4)
     at Module._compile (internal/modules/cjs/loader.js:678:30)
     at Module._extensions..js (internal/modules/cjs/loader.js:689:10)
     at Object.require.extensions.(anonymous function) [as .js] (/home/xxx/node_modules/babel-register/lib/node.js:152:7)
     at Module.load (internal/modules/cjs/loader.js:589:32)
     at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
     at Module._load (internal/modules/cjs/loader.js:520:3)
     at Function.module._load (/home/xxx/node_modules/piping/lib/piping.js:218:16)
     at Module.require (internal/modules/cjs/loader.js:626:17)

import Odometer from 'react-odometerjs'
{this.state.someNumber ?  <Odometer value={this.state.someNumber} format="(,ddd)" /> : '--'}

Next.js example is incorrect

Correct syntax for dynamic import requires a callback, such as:

const Odometer = dynamic(() => import("react-odometerjs"), {
  ssr: false,
  loading: () => <div>0</div>,
})

Getting 8 in front of each numbers.

Not sure why. The Odometer module was working fine and then it broke.

<Odometer value={1234} format="(,ddd).dd" />

output

81,828384

Anyone know why?

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.