import type {AnyObject} from '../../types/basic.js'; import type {Point} from '../../types/geometric.js'; import type {Animation} from '../../types/animation.js'; import {isNumber} from '../helpers/helpers.math.js'; export default class Element { static defaults = {}; static defaultRoutes = undefined; x: number; y: number; active = false; options: O; $animations: Record; tooltipPosition(useFinalPosition: boolean): Point { const {x, y} = this.getProps(['x', 'y'], useFinalPosition); return {x, y} as Point; } hasValue() { return isNumber(this.x) && isNumber(this.y); } /** * Gets the current or final value of each prop. Can return extra properties (whole object). * @param props - properties to get * @param [final] - get the final value (animation target) */ getProps

(props: P, final?: boolean): Pick; getProps

(props: P[], final?: boolean): Partial>; getProps(props: string[], final?: boolean): Partial> { const anims = this.$animations; if (!final || !anims) { // let's not create an object, if not needed return this as Record; } const ret: Record = {}; props.forEach((prop) => { ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop as string]; }); return ret; } }