Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lit version wraperBounds incorrect (always at 0, 0) #7

Open
augonis opened this issue Aug 27, 2024 · 0 comments
Open

lit version wraperBounds incorrect (always at 0, 0) #7

augonis opened this issue Aug 27, 2024 · 0 comments

Comments

@augonis
Copy link

augonis commented Aug 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant