jQuery UI & Draggable: Delay Start

This entry is part 6 of 11 in the series jQuery UI Draggable

jQuery UI Draggable – Delay start

Delay the start of dragging for a number of milliseconds with the delay option; prevent dragging until the cursor is held down and dragged a specifed number of pixels with the distance option.

<!doctype html>
    <title>jQuery UI Draggable - Delay start</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.9.1.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='http://codecrawl.com/code/jqueryui/jqueryui_style.css'>
        #draggable, #draggable2 {
            width: 120px;
            height: 120px;
            padding: 0.5em;
            float: left;
            margin: 0 10px 10px 0;
        $(function () {
            $('#draggable').draggable({ distance: 40 });
            $('#draggable2').draggable({ delay: 1000 });

<div id='draggable' class='ui-widget-content'>
    <p>Only if you drag me by 40 pixels, the dragging will start</p>

<div id='draggable2' class='ui-widget-content'>
    <p>Regardless of the distance, you have to drag and wait for 1000ms before dragging starts</p>

Try The Code

In line 21, the disableSelection() method will prevent the mouse from making any text selection.

Series Navigation<< jQuery UI & Draggable: Visual Feedback
jQuery UI & Draggable: Revert >>

Leave a comment

Leave a Reply