Adding a new parameter: _precision.#593
Adding a new parameter: _precision.#593Danjohnsonnj wants to merge 3 commits intoPrinzhorn:masterfrom
Conversation
|
The second commit (f87e217) builds upon the first by allowing a per-element override of the global precision via a 'data-precision' attribute. |
|
First of all thank you for taking the time to write this patch. I have multiple concerns:
now for every pixel you scroll, it moves about as you can see, even the first decimal place changes every pixel you scroll. This means specifying a precision between 1 and 10 does not have any effect.
|
|
I think this would be a good thing to use with :before :after selectors, for example, If someone wants to show from 0% to 95.5%, they could set up something like this: <p class='percentual' data-percent='0' data-0='@data-percent:0' data-1500='@data-percent:95.5'>
</p>.percentual:before {
content: attr(data-percent) "%"
}with this we can avoid showing 10.5375%, and only show 10.53% if we want. I don't know if there's already an easier way to do this without this modification. |
That's a very interesting use-case. But I don't see this being used widely. Also |
|
Yeah, I agree that's not a must have feature 😜 just said to show some use-case |
The interpolation of values could result in values with decimals of an extremely long length, e.g. 'width: 50.12345678901%'. Since scrolling causes browser repaints, which will be impacted by updated CSS values, performance can be negatively impacted.
I'm proposing a new init option: _precision. This will be used to limit the interpolated value returned from _calcInterpolation via the toFixed(n) method. The default will be 10 (which is likely more than enough for most use-cases) or the user-specified value.