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

Element.getSize() instead of Element.getComputedSize() in Mask.resize() #1274

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lorenzos
Copy link
Contributor

@lorenzos lorenzos commented Jul 7, 2014

This fixes bad Mask resizing in case target element has a box-sizing that is not content-box. See #1273.

PS: I don't know why Github is including old commits of mine in this PR, anyway they were already merged before 1.5.0 - and in fact they brings no diffs at all.

@anutron
Copy link
Member

anutron commented Jul 7, 2014

git reset mootools/master --hard
git cherry-pick 1b3fccc

if (this.options.maskMargins) {
dim.x += this.target.getStyle('margin-left').toInt() + this.target.getStyle('margin-right').toInt();
dim.y += this.target.getStyle('margin-top').toInt() + this.target.getStyle('margin-bottom').toInt();
}
Copy link
Member

Choose a reason for hiding this comment

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

getComputedSize does a lot of things, but one of them is that it checks for when the style is auto. Here you'd get NaN when you call .toInt(), I believe, if that's what the style is set to. It also will do this addition for you, telling you what the total margin is on the sides and the top & bottom. Is there a reason you opted to not use it?

If the purpose is to handle the box model stuff, I think all you need to do is change what getComputedSize measures, as you can configure it to use only the element size, the element size + margins, + margins and padding, + margins, padding, and border, etc.

@anutron
Copy link
Member

anutron commented Jul 7, 2014

Any contribution here is always welcome, but before we pull this we'd need to test it. There aren't any specs for Mask yet, sadly, so you can't just go add one or two specs to round it out. So before we can pull it we need to author specs for Mask or you need to make an interactive demo (on jsFiddle, for example) that demonstrates that this works properly with lots of configurations.

Regardless, I'll reiterate that the pull request is most welcome. It may take a short while for us to pull it without the tests so don't fret.

@anutron
Copy link
Member

anutron commented Jul 7, 2014

Just saw your comment here: #1273 (comment)

I understand your reasoning for using getSize, though I'd rather put the energy into fixing getComputedSize if it's broken for various browsers...

@lorenzos
Copy link
Contributor Author

lorenzos commented Jul 8, 2014

@anutron Yes, I wrote my motivations on #1273 :)

Anyway I understand may be better to fix Element.Measure, making it handle box-sizing correctly. I can work on that in case I find some spare time.

You decide whether to leave my issue and my PR opened, or close them and open a new issue about getComputedSize().

@anutron
Copy link
Member

anutron commented Jul 8, 2014

@lorenzos yep. I may not be the one to get to this (either helping with tests or working on element.measure); someone else may beat me to it (my week is rather busy). Will reiterate how much the pull request is appreciated!

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

Successfully merging this pull request may close these issues.

3 participants