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

margins: now in user units, and working for all aspect ratios cases #86

Merged
merged 2 commits into from
Jul 22, 2021

Conversation

jonenst
Copy link
Contributor

@jonenst jonenst commented Feb 1, 2021

see #80

@jonenst
Copy link
Contributor Author

jonenst commented Feb 1, 2021

Not sure how you test this, I used https://codepen.io/jonenst/pen/mdrgwoJ and copypaste to a local file and imported the build like <script src="file:///tmp/svg.panzoom.js/dist/svg.panzoom.js"></script>

The code can probably become shorter by using more symmetries between meet and slice, but I wasn't sure it was worth it, I understand this one better.

Copy link
Member

@Fuzzyma Fuzzyma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you doublecheck that?

preserveAspectRatio.align === preserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN ||
preserveAspectRatio.align === preserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN ||
preserveAspectRatio.align === preserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN) {
viewportLeftOffset = -widthOffset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looking at all the symmetry going on, this should be positive...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think this should be viewportRightOffset and the other one viewportLeftOffset

preserveAspectRatio.align === preserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX ||
preserveAspectRatio.align === preserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX ||
preserveAspectRatio.align === preserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX) {
viewportRightOffset = widthOffset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...while this should be negative.

@Fuzzyma
Copy link
Member

Fuzzyma commented Feb 22, 2021

oh no I hope the whole symmetry is not different now :D. I shorted the code by a lot using symmetry. we'll see ^^

@jonenst
Copy link
Contributor Author

jonenst commented Feb 22, 2021

Yeah the slice mode was broken, the testing XMid/Min/Max and YMid/MinMax were swapped, and there was the bug you noticed, assigning to the wrong variable

@Fuzzyma Fuzzyma mentioned this pull request Jul 21, 2021
@Fuzzyma
Copy link
Member

Fuzzyma commented Jul 21, 2021

@jonenst so I went ahead and simplified the code a bit. I would like you to glance over it in order to make sure that it is still correct. I pushed it to #91
I would like to go break this down further but I don't want to break something on the line

@Fuzzyma Fuzzyma merged commit b432e49 into svgdotjs:master Jul 22, 2021
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

Successfully merging this pull request may close these issues.

2 participants