zoompinch
zoompinch copied to clipboard
lit version wraperBounds incorrect (always at 0, 0)
Thanks for the tool.
In lit version Pancake.wrapperBounds always ends up with {x:0 y:0} because (at least in chrome) ResizeObserverEntry.contentRect always has x=0, y=0, which then throws off client-canvas coordinate transformations
For now I've patched the ResizeObserver callback to use getClientRects instead. Though ResizeObserver is likely not the right tool for the purpose.
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
if (!this._wrapper) {
return console.error('No wrapper found');
}
this.resizeObserver = new ResizeObserver((entries) => {
//this.wrapperBounds = entries[0].contentRect;
this.wrapperBounds = entries[0].target.getClientRects()[0];
});
this.resizeObserver.observe(this._wrapper);
}
I can make a PR with this patch, or even work on better solution.