2a5bac2bb3
* major JSDoc write up * removed ESLint `no-bitwise` exception, it only applies to specific functions and not the entire code * the `SVGCubicMorph` component will remove un-necessary `Z` path commands when is the case for better out of the box animation * fixed a minor disambiguation with `filterEffects` and `drop-shadow` property and its `dropshadow` interpolation function * TypeScript strong: all files are modules, easy to implement in any third party app * updated `CubicBezier` and SVGPathCommander * code cleanup
19 lines
610 B
JavaScript
19 lines
610 B
JavaScript
/**
|
|
* Translate 3D Interpolation Function.
|
|
*
|
|
* @param {number[]} a start [x,y,z] position
|
|
* @param {number[]} b end [x,y,z] position
|
|
* @param {string} u unit, usually `px` degrees
|
|
* @param {number} v progress
|
|
* @returns {string} the interpolated 3D translation string
|
|
*/
|
|
export default function translate3d(a, b, u, v) {
|
|
const translateArray = [];
|
|
for (let ax = 0; ax < 3; ax += 1) {
|
|
translateArray[ax] = (a[ax] || b[ax]
|
|
// eslint-disable-next-line no-bitwise
|
|
? ((a[ax] + (b[ax] - a[ax]) * v) * 1000 >> 0) / 1000 : 0) + u;
|
|
}
|
|
return `translate3d(${translateArray.join(',')})`;
|
|
}
|