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

[Bug] Positioning is wrong when transform: scale() is used #75

Open
sinedied opened this issue Nov 8, 2022 · 1 comment
Open

[Bug] Positioning is wrong when transform: scale() is used #75

sinedied opened this issue Nov 8, 2022 · 1 comment

Comments

@sinedied
Copy link

sinedied commented Nov 8, 2022

I'm using RemarkJS to create my slides, and I would love to use Rough notation to highlight parts of my talk!

When I tried to integrate it, I noticed the positioning was wrong and tried to understand why: remark use a "scaler" container to always have the slides centered with the same aspect ratio, and it uses transform: scale() to achieve that.

When the scale value is different than 1, the Rough notation positioning is shifted.

I would love to know if you are aware of any workaround!

Thanks

@sinedied
Copy link
Author

sinedied commented Nov 9, 2022

I made a small and imperfect workaround for now, everytime I create an annotation, I apply to the SVG the inverse of the scale transform:

  // Fix scale
  const scaler = document.querySelector('.remark-slide-scaler');
  const scale = Number(/scale\((\d+\.?\d*)\)/.exec(scaler.style.transform)[1]);
  annotation._svg.style.transform = `scale(${1/scale})`;

It doesn't get updated through resize, but it's fine for my use case.
Would love to see a more robust solution though!

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