Bug Tracker

Opened 12 years ago

Closed 12 years ago

#2096 closed bug (fixed)

ui.mouse: appendTo broken

Reported by: wehriam Owned by: paul
Priority: major Milestone: 1.2.2
Component: ui Version: 1.2.1
Keywords: mouse draggable Cc:
Blocked by: Blocking:

Description

Lines 141-142 in UI mouse in rev 4311:

			if(o.appendTo == 'parent') { // Let's see if we have a positioned parent
				var cp = a.parentNode;
				while (cp) {
					if(cp.style && ($(cp).css('position') == 'relative' || $(cp).css('position') == 'absolute')) {
						o.pp = cp;
						o.po = $(cp).offset();
						o.ppOverflow = !!($(o.pp).css('overflow') == 'auto' || $(o.pp).css('overflow') == 'scroll'); //TODO!
						break;	
					}
					cp = cp.parentNode ? cp.parentNode : null;
				};
				
				if(!o.pp) o.po = { top: 0, left: 0 };
			}

If "appendTo" is specified (for example when using a draggable) the this.options.po object goes unset. This causes problems in ui.draggable and likely elsewhere.

			if(o.appendTo == 'parent') { // Let's see if we have a positioned parent
				var cp = a.parentNode;
				while (cp) {
					if(cp.style && ($(cp).css('position') == 'relative' || $(cp).css('position') == 'absolute')) {
						o.pp = cp;
						o.po = $(cp).offset();
						o.ppOverflow = !!($(o.pp).css('overflow') == 'auto' || $(o.pp).css('overflow') == 'scroll'); //TODO!
						break;	
					}
					cp = cp.parentNode ? cp.parentNode : null;
				};
				
				if(!o.pp) o.po = { top: 0, left: 0 };
			} else { 
				var cp = $(o.appendTo)[0];
				while (cp) {
					if(cp.style && ($(cp).css('position') == 'relative' || $(cp).css('position') == 'absolute')) {
						o.pp = cp;
						o.po = $(cp).offset();
						o.ppOverflow = !!($(o.pp).css('overflow') == 'auto' || $(o.pp).css('overflow') == 'scroll'); //TODO!
						break;	
					}
					cp = cp.parentNode ? cp.parentNode : null;
				};

				if(!o.pp) o.po = { top: 0, left: 0 };
			}

This seems to fix the problem. Sorry - for the time being I am not familiar enough with the codebase to give a more elegant solution.

Change History (2)

comment:1 Changed 12 years ago by paul

Owner: set to paul
Status: newassigned

You're absolutely right. Thanks for pointing it out. It's fixed in the upcoming version.

comment:2 Changed 12 years ago by paul

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.