#7485 closed bug (fixed)
Resizable: Containment calculation is wrong when containment element is not the immediate parent
Reported by: | Hancoque | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.11.0 |
Component: | ui.resizable | Version: | 1.8.13 |
Keywords: | haspatch | Cc: | |
Blocked by: | Blocking: |
Description
There's a problem with the resizable component when using a containment element that is not the parent of the resizable element.
I found out that the allowed width computation differs from the allowed height computation. There's additional code for the former and it seems that a workaround for the bug is already in place but it is only triggered if the containment element is also the parent element:
var isParent = self.containerElement.get(0) == self.element.parent().get(0), isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position')); if(isParent && isOffsetRelative) woset -= self.parentData.left;
So, a possible approach to fix this bug is to get rid of the isParent
check.
Test case: http://jsbin.com/oduba4
Try to resize the blue element to the full width of the gray element. It won't work, though it should. The space missing on the right equals the left offset of the containment element.
While investigating this bug I noticed that there are some other differences between the containment calculations for width and height in the same function as the code posted above is in. You may want to take a look at those differences as removing them also fixes the bug. But I don't know if these differences are there for a reason and address other issues.
Here's an additional subtraction of cop.left
at the end:
self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
vs
self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);}
And Here cop
is used instead of co
in the else-case:
var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
vs
hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
Change History (15)
comment:1 Changed 12 years ago by
comment:2 Changed 11 years ago by
Milestone: | 1.9.0 → 2.0.0 |
---|
comment:3 Changed 11 years ago by
Status: | new → open |
---|---|
Summary: | Containment calculation is wrong when containment element is no parent → Resizable: Containment calculation is wrong when containment element is not the immediate parent |
Still an issue in 1.9.1 - http://jsbin.com/oduba4/3.
comment:5 Changed 11 years ago by
Keywords: | haspatch added |
---|
See duplicate ticket #8217 for a proposed patch.
comment:7 Changed 11 years ago by
Here's another good test case from #8895 - http://jsfiddle.net/TkHUE/33/.
comment:9 Changed 11 years ago by
#9174 had this test case against master - http://jsfiddle.net/v392b/. And a discussion on what the problem in the code might be.
comment:10 Changed 11 years ago by
this bug is very easy to fix, so why has this issue been open for 21 months?
comment:11 Changed 11 years ago by
@scato.eggen We've been very busy. Feel free to send a pull request with a unit test!
comment:14 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Resizable: containment now works with non - immediate children
Fixes #7485 Closes gh-1130
Changeset: c03cb8079c6984fb9286a64d980d367d86b9cd8b
comment:15 Changed 10 years ago by
Milestone: | 2.0.0 → 1.11.0 |
---|
The bug still exists in jQuery UI 1.8.14.