Skip to main content

Search and Top Navigation

#5569 closed bug (fixed)

Opened April 30, 2010 12:50PM UTC

Closed March 08, 2013 02:42AM UTC

Last modified March 08, 2013 02:43AM UTC

Draggable: Containment incorrectly calculates padding and border

Reported by: Daazku Owned by:
Priority: minor Milestone: 1.10.2
Component: ui.draggable Version: 1.8
Keywords: haspatch Cc:
Blocked by: Blocking:
Description

Draggable containement calculation is wrong because

this.containment = [
    co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
    co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
    co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
    co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
];

should be

this.containment = [
    co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
    co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
    co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
    co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
];

(replaced borderLeftWidth by borderRightWidth for right containement and same for bottom)

Attachments (0)
Change History (7)

Changed October 11, 2012 09:07PM UTC by scottgonzalez comment:1

milestone: TBD2.0.0

Changed October 26, 2012 04:03AM UTC by mikesherov comment:2

keywords: containementhaspatch
status: newopen

Changed October 26, 2012 04:04AM UTC by mikesherov comment:3

summary: Containment size calculation is wrong.Draggable: Containment incorrectly calculates padding and border

Changed January 23, 2013 02:46AM UTC by tj.vantoll comment:4

Test case - http://jsfiddle.net/tj_vantoll/maP9S/. I verified that the recommended fix indeed fixes the problem.

Changed January 26, 2013 08:33PM UTC by tj.vantoll comment:5

Changed March 08, 2013 02:42AM UTC by TJ VanToll comment:6

resolution: → fixed
status: openclosed

Draggable: Fix border containment. Fixed #5569 - Draggable: Containment incorrectly calculates padding and border

Changeset: 6358695df18722d8c7e99437365db42cf4957626

Changed March 08, 2013 02:43AM UTC by tj.vantoll comment:7

milestone: 2.0.01.10.2