@cbpds/web-components
Version:
Web components for the CBP Design System.
58 lines (52 loc) • 1.85 kB
JavaScript
/*!
* CPB Design System web components - built with Stencil
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const index = require('./index-2207639d.js');
const cbpResizeObserverCss = "cbp-resize-observer{max-width:100%;display:block;overflow:visible}";
const CbpResizeObserverStyle0 = cbpResizeObserverCss;
const CbpResizeObserver = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.resized = index.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 (index.h(index.Host, { key: 'cf5ffc573fe64cbc9e7cb469edbe2758c6a4fd66' }, index.h("slot", { key: '77b1f2e34121b5c5bb5106199bbfaa23bb015716' })));
}
get host() { return index.getElement(this); }
};
CbpResizeObserver.style = CbpResizeObserverStyle0;
exports.cbp_resize_observer = CbpResizeObserver;
//# sourceMappingURL=cbp-resize-observer.cjs.entry.js.map