Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/unit/draggable/draggable.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>jQuery UI Draggable Test Suite</title>

<script src="../../../external/requirejs/require.js"></script>
<script src="../../lib/css.js" data-modules="core"></script>
<script src="../../lib/css.js" data-modules="core draggable"></script>
<script src="../../lib/bootstrap.js" data-widget="draggable"></script>
<style>
#main {
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/draggable/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,17 +802,20 @@ QUnit.test( "cursorAt, switching after initialization", function( assert ) {
} );

QUnit.test( "disabled", function( assert ) {
assert.expect( 6 );
assert.expect( 9 );

var element = $( "#draggable1" ).draggable();

testHelper.shouldMove( assert, element, "disabled: default" );
assert.equal( element.css( "touch-action" ), "none", "touch-action: default" );

element.draggable( "option", "disabled", true );
testHelper.shouldNotDrag( assert, element, "option: disabled true" );
assert.equal( element.css( "touch-action" ), "auto", "touch-action: disabled true" );

element.draggable( "option", "disabled", false );
testHelper.shouldMove( assert, element, "option: disabled false" );
assert.equal( element.css( "touch-action" ), "none", "touch-action: disabled false" );
} );

QUnit.test( "{ grid: [50, 50] }, relative", function( assert ) {
Expand Down
2 changes: 1 addition & 1 deletion themes/base/draggable.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Released under the MIT license.
* http://jquery.org/license
*/
.ui-draggable-handle {
.ui-draggable-handle-enabled {
-ms-touch-action: none;
touch-action: none;
}
13 changes: 13 additions & 0 deletions ui/widgets/draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ $.widget( "ui.draggable", $.ui.mouse, {
this._addClass( "ui-draggable" );
}
this._setHandleClassName();
if ( !this.options.disabled ) {
this._addClass( this.handleElement, "ui-draggable-handle-enabled" );
}

this._mouseInit();
},
Expand All @@ -91,6 +94,16 @@ $.widget( "ui.draggable", $.ui.mouse, {
}
},

_setOptionDisabled: function( value ) {

// Remove touch-action for disabled draggables
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line before comments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But implementation is good

if ( value ) {
this._removeClass( this.handleElement, "ui-draggable-handle-enabled" );
} else {
this._addClass( this.handleElement, "ui-draggable-handle-enabled" );
}
},

_destroy: function() {
if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
this.destroyOnClear = true;
Expand Down