Comments (2)
I think it's a bug.
For back it's just a matter of reordering the operations to avoid bad rounding.
backIn(t) is computed as t * t * ((s + 1) * t - s)
where s is the "overshoot" parameter. If computed as t * t * (s * (t - 1) + t)
it will return 1 for t=1, with no additional cost (same number of multiplications and additions).
For elastic, and exp the formula is not really expected to give 0 in 0 or 1 in 1 as it uses Math.pow(2,-10) instead of 0.
A solution for these would be to introduce easePow(x) = (Math.pow(2, 10 * (x-1)) - 0.0009765625) * 1.0009775171065494
(the two constants being 2^-10
and 1/(1-2^-10)
) and use it internally in lieu of Math.pow(2, 10 * (x-1))
. This would have an added cost of 1 multiplication and 1 addition. It also means we have to change all the tests.
Finally for sinIn there doesn't seem to be a solution other than an equality test (t === 1 ? 1 : Math.cos(…))
from d3-ease.
I've pushed a rather simple solution for back and for sin, and a second commit solves it for elastic and exp (but breaks all the tests).
from d3-ease.
Related Issues (16)
- Consider using a more generic easing library HOT 5
- Accelerate, then coast?
- Rename ease(type[, parameters…]) to bind?
- Remove non-in aliases.
- Need an ease interface. HOT 14
- Easing/Transitioning in Chrome HOT 4
- update docs with npm version HOT 1
- README needs API reference.
- README references obsolete APIs. HOT 3
- Cubic Bézier easing? HOT 1
- broken Map polyfill HOT 1
- Register with bower. HOT 1
- Don’t ignore NaN parameters? HOT 2
- Symbols, not strings? HOT 1
- bounce optional params HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-ease.