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} prop the property name
|
|
|
|
*/
|
2021-03-30 11:23:29 +02:00
|
|
|
export function onStartBgPos(prop) {
|
2021-12-08 22:43:31 +01:00
|
|
|
if (this.valuesEnd[prop] && !KEC[prop]) {
|
|
|
|
KEC[prop] = (elem, a, b, v) => {
|
|
|
|
/* eslint-disable -- no-bitwise & no-param-reassign impossible to satisfy */
|
2021-03-30 11:23:29 +02:00
|
|
|
elem.style[prop] = `${(numbers(a[0], b[0], v) * 100 >> 0) / 100}% ${((numbers(a[1], b[1], v) * 100 >> 0) / 100)}%`;
|
2021-12-08 22:43:31 +01:00
|
|
|
/* eslint-enable -- no-bitwise & no-param-reassign impossible to satisfy */
|
2021-03-30 11:23:29 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Component Base Object
|
2021-12-08 22:43:31 +01:00
|
|
|
const BackgroundPositionBase = {
|
2021-03-30 11:23:29 +02:00
|
|
|
component: 'baseBackgroundPosition',
|
|
|
|
property: 'backgroundPosition',
|
|
|
|
Interpolate: { numbers },
|
|
|
|
functions: { onStart: onStartBgPos },
|
|
|
|
};
|
2021-12-08 22:43:31 +01:00
|
|
|
export default BackgroundPositionBase;
|