Draggable: Style updates

Ref #14246
This commit is contained in:
Alexander Schmitz 2015-08-24 08:59:44 -04:00
parent 0cab9f0a2f
commit 8336ba7b69
7 changed files with 580 additions and 561 deletions

View File

@ -182,9 +182,11 @@ test( "scroll offset with fixed ancestors", function() {
var startValue = 300,
element = $( "#draggable1" )
// http://bugs.jqueryui.com/ticket/5009
// scroll not working with parent's position fixed
.wrap( "<div id='wrapper' />" )
// http://bugs.jqueryui.com/ticket/9612
// abspos elements inside of fixed elements moving away from the mouse when scrolling
.wrap( "<div id='wrapper2' />" )

View File

@ -8,6 +8,7 @@ return $.extend( helper, {
// TODO: remove the unreliable offset hacks
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
unreliableContains: ( function() {
@ -145,6 +146,7 @@ return $.extend( helper, {
},
trackAppendedParent: function( el ) {
// TODO: appendTo is currently ignored if helper is original (see #7044)
el.draggable( "option", "helper", "clone" );

View File

@ -274,6 +274,7 @@ test( "connectToSortable, dragging out of a sortable", function() {
} );
$( element ).one( "dragstop", function( event, ui ) {
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
deepEqual( ui.helper.offset(), offsetExpected, "draggable offset is correct" );
@ -308,6 +309,7 @@ asyncTest( "connectToSortable, dragging clone into sortable", function() {
$( sortable ).one( "sort", function( event, ui ) {
offsetPlaceholder = ui.placeholder.offset();
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
deepEqual( ui.helper.offset(), offsetSortable, "sortable offset is correct" );
@ -315,6 +317,7 @@ asyncTest( "connectToSortable, dragging clone into sortable", function() {
} );
$( sortable ).one( "sortstop", function( event, ui ) {
// http://bugs.jqueryui.com/ticket/9675
// Animation issue with revert and connectToSortable
deepEqual( ui.item.offset(), offsetPlaceholder, "offset eventually equals placeholder" );
@ -944,6 +947,7 @@ function testHelperPosition( scrollPositions, position, helper, scrollElements,
},
positions = [ "absolute", "fixed", "relative", "static" ],
helpers = [ "original", "clone" ],
// static is not an option here since the fixture is in an absolute container
scrollPositions = [ "relative", "absolute", "fixed" ];
@ -1153,6 +1157,7 @@ test( "#6817: auto scroll goes double distance when dragging", function( assert
scroll: true,
stop: function( e, ui ) {
equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" );
// TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
assert.close( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" );
}
@ -1341,6 +1346,7 @@ test( "#8459: element can snap to an element that was removed during drag", func
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
// TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
assert.close( element.offset().left, newX, 1, "doesn't snap to a removed element" );
assert.close( element.offset().top, newY, 1, "doesn't snap to a removed element" );
@ -1466,6 +1472,7 @@ test( "iframeFix", function() {
element.one( "drag", function() {
var div = $( this ).children().not( "iframe" );
// http://bugs.jqueryui.com/ticket/9671
// iframeFix doesn't handle iframes that move
equal( div.length, 1, "blocking div added as sibling" );

View File

@ -244,6 +244,7 @@ $.widget("ui.draggable", $.ui.mouse, {
},
_mouseDrag: function( event, noPropagation ) {
// reset any necessary cached properties (see #5009)
if ( this.hasFixedAncestor ) {
this.offset.parent = this._getParentOffset();
@ -313,6 +314,7 @@ $.widget("ui.draggable", $.ui.mouse, {
// Only need to focus if the event occurred on the draggable itself, see #10527
if ( this.handleElement.is( event.target ) ) {
// The interaction is over; whether or not the click resulted in a drag, focus the element
this.element.trigger( "focus" );
}
@ -612,6 +614,7 @@ $.widget("ui.draggable", $.ui.mouse, {
}
if ( o.grid ) {
//Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || top - this.offset.click.top > containment[ 3 ] ) ? top : ( ( top - this.offset.click.top >= containment[ 1 ] ) ? top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
@ -740,6 +743,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
// its original helper, not the shared helper from draggable
sortable.options.helper = sortable.options._helper;
} else {
// Prevent this Sortable from removing the helper.
// However, don't set the draggable to remove the helper
// either as another connected Sortable may yet handle the removal.
@ -763,6 +767,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
innermostIntersecting = true;
$.each( draggable.sortables, function() {
// Copy over variables that sortable's _intersectsWith uses
this.positionAbs = draggable.positionAbs;
this.helperProportions = draggable.helperProportions;
@ -779,6 +784,7 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
}
if ( innermostIntersecting ) {
// If it intersects, we use a little isOver variable and set it once,
// so that the move-in stuff gets fired only once.
if ( !sortable.isOver ) {
@ -832,12 +838,14 @@ $.ui.plugin.add( "draggable", "connectToSortable", {
if ( sortable.currentItem ) {
sortable._mouseDrag( event );
// Copy the sortable's position because the draggable's can potentially reflect
// a relative position, while sortable is always absolute, which the dragged
// element has now become. (#8809)
ui.position = sortable.position;
}
} else {
// If it doesn't intersect with the sortable, and it intersected before,
// we fake the drag stop of the sortable, but make sure it doesn't remove
// the helper by using cancelHelperRemoval.