2021-12-08 22:43:31 +01:00
|
|
|
import KEC from '../objects/kute';
|
|
|
|
import numbers from '../interpolation/numbers';
|
2021-03-30 11:23:29 +02:00
|
|
|
|
|
|
|
// Component Functions
|
2021-12-08 22:43:31 +01:00
|
|
|
/**
|
|
|
|
* Sets the property update function.
|
|
|
|
* @param {string} tweenProp the property name
|
|
|
|
*/
|
2021-03-30 11:23:29 +02:00
|
|
|
export function onStartClip(tweenProp) {
|
2021-12-08 22:43:31 +01:00
|
|
|
if (this.valuesEnd[tweenProp] && !KEC[tweenProp]) {
|
|
|
|
KEC[tweenProp] = (elem, a, b, v) => {
|
2021-03-30 11:23:29 +02:00
|
|
|
let h = 0; const
|
|
|
|
cl = [];
|
|
|
|
for (h; h < 4; h += 1) {
|
2021-12-08 22:43:31 +01:00
|
|
|
const c1 = a[h].v;
|
|
|
|
const c2 = b[h].v;
|
|
|
|
const cu = b[h].u || 'px';
|
|
|
|
// eslint-disable-next-line no-bitwise -- impossible to satisfy
|
2021-03-30 11:23:29 +02:00
|
|
|
cl[h] = ((numbers(c1, c2, v) * 100 >> 0) / 100) + cu;
|
|
|
|
}
|
2021-12-08 22:43:31 +01:00
|
|
|
// eslint-disable-next-line no-param-reassign -- impossible to satisfy
|
2021-03-30 11:23:29 +02:00
|
|
|
elem.style.clip = `rect(${cl})`;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Component Base
|
2021-12-08 22:43:31 +01:00
|
|
|
const ClipPropertyBase = {
|
2021-03-30 11:23:29 +02:00
|
|
|
component: 'baseClip',
|
|
|
|
property: 'clip',
|
|
|
|
// defaultValue: [0,0,0,0],
|
|
|
|
Interpolate: { numbers },
|
|
|
|
functions: { onStart: onStartClip },
|
|
|
|
};
|
|
|
|
|
2021-12-08 22:43:31 +01:00
|
|
|
export default ClipPropertyBase;
|