@adoratorio/apollo
Version:
A JS library for custom cursor
42 lines • 1.39 kB
JavaScript
class SingleTarget {
element;
descriptor;
id;
boundingRect = {};
boundings = {};
constructor(element, descriptor, id) {
this.element = element;
this.descriptor = descriptor;
this.id = `${this.descriptor.id}-${id}`;
this.element._apolloId = this.id;
if (typeof this.descriptor.callback !== 'function')
this.descriptor.callback = () => { };
this.calculateBoundings();
}
frame(delta) {
this.calculateBoundings();
}
render(delta) {
}
postRender(delta) {
}
calculateBoundings() {
this.boundingRect = this.element.getBoundingClientRect();
let offsetX = 0;
let offsetY = 0;
if (this.descriptor.offset && this.descriptor.offset.x)
offsetX = this.descriptor.offset.x;
if (this.descriptor.offset && this.descriptor.offset.y)
offsetY = this.descriptor.offset.y;
this.boundings = {
top: this.boundingRect.top - offsetY,
bottom: this.boundingRect.bottom + offsetY,
left: this.boundingRect.left - offsetX,
right: this.boundingRect.right + offsetX,
width: this.boundingRect.width + (offsetX * 2),
height: this.boundingRect.height + (offsetY * 2),
};
}
}
export default SingleTarget;
//# sourceMappingURL=SingleTarget.js.map