-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Make reading element dimensions work regardless of transforms #633
Make reading element dimensions work regardless of transforms #633
Conversation
A friendly reminder: Please start a new discussion before starting any work to avoid doing unnecessary work. Thank you for your contribution! I don't think this approach will work with a Best, |
Sorry, I didn't know a discussion was necessary. I just tried adding dir="rtl" to the node: |
Thanks @javiergonzalezGenially, One more thing I have in mind at the time of writing: Have you checked if all tests in Best, |
@javiergonzalezGenially I have to update the contribution guidelines but the reason is actually there for you. Now this PR/initiative is great and is actually on my TODO, but sometimes devs do significant amount of work on something that isn't aligned with the Embla vision without starting a discussion. So they practically waste their time which could be avoided with a discussion 🙂. |
@davidjerleke just made a commit that fixed the unit tests :) |
Thanks a ton @javiergonzalezGenially. I will test this as soon as possible. Thank you very much for contributing ⭐! |
Thanks to you for creating the lib! I don't want to seem too demanding, but if you could release a rc with the fix at some point would be really appreciated ;) |
@javiergonzalezGenially sure. I will release an RC after I’ve tested this and I’ve reviewed all code. I think this is a great feature to test with RC before the stable v8 release. |
@javiergonzalezGenially I will have to change some stuff on this PR before we can merge this because I found cases where the measurements fail. Especially when setting It seems to be caused by the fact that Best, |
@davidjerleke sure, maybe you can use https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent to get the relative parent element and sum all the offsets until that offsetParent returns null? |
@javiergonzalezGenially thanks for the idea! I’m looking into possible solutions. I have to take bundle size, performance, readability and complexity into account so will try to find a good solution. |
Sure, I wasn't talking of anything complex, just something like:
After that it should be a matter of changing getNodeRect to do
instead of
|
@javiergonzalezGenially thanks for the code snippet. I probably wasn’t clear: I didn’t mean that your suggestion was complex, I just wanted to explain that I want to consider more than one solution, what I will be looking into and their pros and cons. Sorry if I wasn’t clear 🙂. Cheers! |
Ah! sure, no problem :) |
@javiergonzalezGenially I think this is ready to merge. I will let you know when the experimental RC is out which will be |
@javiergonzalezGenially I've released |
Thanks a lot!! |
When using the carousel inside a container with a scale transform applied the carousel doesn't work properly because it uses to measure nodes getBoundingClientRect, which returns a rect which is already scaled.
The proposed fix (tested working in the playground) uses instead offsetLeft/offsetWidth etc, which are unscaled.