Giter Site home page Giter Site logo

Comments (5)

javierbyte avatar javierbyte commented on June 18, 2024

@AoDev sounds like a good idea. How about customFunctionRender receiving an extra argument to tell if it's currently being animated?

from react-number-easing.

AoDev avatar AoDev commented on June 18, 2024

I think it can work, I am thinking of pros and cons.

If we can provide 2 functions, then it's easier to use the component, since it would stay more "declarative style" and there would be no need to check anything.

From performance point of view (like having many animated numbers), if we can make things in a way that there is no need to check if the transition has finished then it might be a good thing. Just call the "customFinalRender" internally if it was provided, or the customRender / defaultRender.

If we provide 1 function with a parameter, then it's less props to provide to the component but I dont know if it can be optimized the same way than with 2.

from react-number-easing.

AoDev avatar AoDev commented on June 18, 2024

Continuing my comment above, we have different choices.

<NumberEasing
  value={10}
  decimals={0}
  finalRender={(num) => num.toFixed(2)}
  ease="quintInOut"
/>
<NumberEasing
  value={10}
  customRender={(num) => num.toFixed(0)}
  finalRender={(num) => num.toFixed(2)}
  ease="quintInOut"
/>
<NumberEasing
  value={10}
  customRender={(num, final) => final ? num.toFixed(2) : num.toFixed(0)}
  ease="quintInOut"
/>

I guess all are fine but maybe there is one that could take advantage of the internal mechanism of the component if it knows when the final render will occur.

from react-number-easing.

javierbyte avatar javierbyte commented on June 18, 2024

hey @AoDev, thank you for detailing those options. I think I like having a single function best:

<NumberEasing
  value={10}
  customRender={(num, final) => final ? num.toFixed(2) : num.toFixed(0)}
  ease="quintInOut"
/>

makes for an easier export of render functions. I don't think there is a performance difference between having them as a single function or separate funcitons.

What do you think? I can add the parameter.

from react-number-easing.

AoDev avatar AoDev commented on June 18, 2024

hello @javierbyte , I just realised I had to answer you (one year ago lol).
Yes, it's good to have a final flag in custom render as a solution : )

from react-number-easing.

Related Issues (10)

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.