Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions Source/Interface/Mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,23 @@ var Mask = new Class({
},

resize: function(x, y){
var opt = {
styles: ['padding', 'border']
};
if (this.options.maskMargins) opt.styles.push('margin');

var dim = this.target.getComputedSize(opt);
var dim = this.target.getSize();
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.


if (this.target == document.body){
this.element.setStyles({width: 0, height: 0});
var win = window.getScrollSize();
if (dim.totalHeight < win.y) dim.totalHeight = win.y;
if (dim.totalWidth < win.x) dim.totalWidth = win.x;
if (dim.y < win.y) dim.y = win.y;
if (dim.x < win.x) dim.x = win.x;
}

this.element.setStyles({
width: Array.pick([x, dim.totalWidth, dim.x]),
height: Array.pick([y, dim.totalHeight, dim.y])
width: Array.pick([x, dim.x]),
height: Array.pick([y, dim.y])
});

return this;
Expand Down