@cbpds/web-components
Version:
Web components for the CBP Design System.
54 lines (50 loc) • 1.79 kB
JavaScript
/*!
* CPB Design System web components - built with Stencil
*/
import { r as registerInstance, c as createEvent, h, a as Host, g as getElement } from './index-0f6e3adc.js';
const cbpResizeObserverCss = "cbp-resize-observer{max-width:100%;display:block;overflow:visible}";
const CbpResizeObserverStyle0 = cbpResizeObserverCss;
const CbpResizeObserver = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.resized = createEvent(this, "resized", 7);
this.debounce = 0;
}
async getCurrentSize() {
return this.getClientRect();
}
getClientRect() {
return this.host.getBoundingClientRect();
}
componentDidLoad() {
this.observedEl = this.host;
this.observer = new ResizeObserver(([{ contentRect }]) => {
const { width, height, top, bottom, left, right, x, y } = contentRect;
const customEvent = {
host: this.host,
width: width,
height: height,
top: top,
bottom: bottom,
left: left,
right: right,
x: x,
y: y
};
this.resized.emit(customEvent);
});
this.observer.observe(this.observedEl);
}
disconnectedCallback() {
if (this.observer) {
this.observer.unobserve(this.observedEl);
}
}
render() {
return (h(Host, { key: '4efdc4d695a87973af58a0a6d79ed3d1448807e3' }, h("slot", { key: '2fb1725da9e2ad6165b190cc5a4e7e31ed79979f' })));
}
get host() { return getElement(this); }
};
CbpResizeObserver.style = CbpResizeObserverStyle0;
export { CbpResizeObserver as cbp_resize_observer };
//# sourceMappingURL=cbp-resize-observer.entry.js.map