Experience-Monks / f1

A stateful ui library
MIT License
78 stars 5 forks source link

Percent #16

Closed njam3 closed 8 years ago

njam3 commented 8 years ago

@mikkoh The only caveat with this is that it must be from a percent to a percent (in the states file). It can not go between percent and number.

mikkoh commented 8 years ago

Sooo this is pretty well how I was gonna implement it. One issue I had was what if you did something like this:

{
  start: {
    ui: {
      left: 10
    }
  },

  end: {
    ui: {
      left: '100%'
    }
  }
}

I also wonder if there are more performant ways of doing this than using parseFloat during every frame of execution.

njam3 commented 8 years ago

@mikkoh I tried it without parseFloat and got some very weird results going from 100 to 0 without parseFloat caused it to go from 0 to -100. I'm not sure if there is a solution to going from a static number to a percent number, but i don't think its need, we could have a warning and interpolate the number as 10%

njam3 commented 8 years ago

@mikkoh I changed parseFloat to *1 as its apparently more performant: http://phrogz.net/js/string_to_number.html

njam3 commented 8 years ago

@mikkoh Actually, i updated it again to be Number() as that seems the quickest and the most readable.