Ticket #7485 (open bug)
Resizable: Containment calculation is wrong when containment element is not the immediate parent
|Reported by:||Hancoque||Owned by:|
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));
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 ),
hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
- Status changed from new to open
- Summary changed from Containment calculation is wrong when containment element is no parent to Resizable: Containment calculation is wrong when containment element is not the immediate parent