Skip to main content

Search and Top Navigation

#9733 closed bug (fixed)

Opened January 08, 2014 08:03PM UTC

Closed January 20, 2014 06:10PM UTC

Last modified January 20, 2014 06:10PM UTC

Draggable: Changing containment option doesn't work

Reported by: benth Owned by: benth
Priority: minor Milestone: 1.11.0
Component: ui.draggable Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:
Description

If containment is such that relative_container is set, and then containment changes e.g. to 'window', the old relative_container will remain instead of being unset.

Attachments (0)
Change History (9)

Changed January 08, 2014 08:20PM UTC by scottgonzalez comment:1

owner: → benth
status: newpending

Please provide a reduced test case showing the problem. Describe what you're doing, not the internal code.

Changed January 08, 2014 08:40PM UTC by benth comment:2

status: pendingnew

I have a draggable element that had its containment set to another DOM element, but later would get set to 'window'. After that, if I was scrolled down the page, and started dragging the element, the element would skip up. I found that relative_container was set to the old containment.

relative_container is only set in _setContainer, at the end, but there are many code paths in _setContainer that return early. I fixed my problem by setting relative_container to null for all these paths.

You'll have to wait for a test case.

Changed January 08, 2014 08:52PM UTC by tj.vantoll comment:3

status: newpending

Replying to [comment:2 benth]:

You'll have to wait for a test case.

We need one to look into this. You can use this as a starting point: http://jsfiddle.net/tj_vantoll/fwk8R/.

Changed January 09, 2014 12:40AM UTC by benth comment:4

status: pendingnew

Changed January 09, 2014 12:42AM UTC by scottgonzalez comment:5

status: newpending

You forgot to click Update in order to generate your fiddle. That's just a copy of the original fiddle that tj.vantoll provided.

Changed January 09, 2014 12:51AM UTC by benth comment:6

_comment0: My apologies. Try this: \ \ http://jsfiddle.net/JnGJN/1/ \ 1389228783445323
status: pendingnew

My apologies. Try this:

http://jsfiddle.net/JnGJN/3/

Changed January 09, 2014 12:57AM UTC by scottgonzalez comment:7

status: newopen
summary: Draggable: relative_container fails to get unset when containment changesDraggable: Changing containment option doesn't work

Changed January 20, 2014 06:10PM UTC by Ben Higgins comment:8

resolution: → fixed
status: openclosed

Draggable: fix changing containment

If containment was set such that relative_container is set by

_setContainment, and then containment changes to e.g. "document",

"window", or an array, relative_container would not be unset, causing

incorrect containment of the draggable.

Add a unittest to check that containment with an array works after

previously being set to "parent".

Fixes #9733

Closes gh-1176

Changeset: 0bb807bb42af87bf4c6dd4d71808b12c08d316e7

Changed January 20, 2014 06:10PM UTC by tj.vantoll comment:9

milestone: none1.11.0