Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#5569 closed bug (fixed)

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)

Change History (7)

comment:1 Changed 11 years ago by Scott González

Milestone: TBD2.0.0

comment:2 Changed 11 years ago by mikesherov

Keywords: haspatch added; containement removed
Status: newopen

comment:3 Changed 11 years ago by mikesherov

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

comment:4 Changed 11 years ago by tj.vantoll

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

comment:6 Changed 11 years ago by TJ VanToll

Resolution: fixed
Status: openclosed

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

Changeset: 6358695df18722d8c7e99437365db42cf4957626

comment:7 Changed 11 years ago by tj.vantoll

Milestone: 2.0.01.10.2
Note: See TracTickets for help on using tickets.