3

i am trying to figure out how to make draggable and scollable work simulatnoeusuly:

http://159.8.132.20/alldevice/

when u try to drag image on either side draggable action also starts, i want that area to be easily scrollable, means when i am scrolling draggble event should not be there

 var $drop = $('#canvas-drop-area,#canvas-drop-area1'),
        $gallery = $('#image-list li'),
        $draggedImage = null,
        $canvasp1old = null,
        $canvasp2old = null;
    $gallery.draggable({
        //refreshPositions: true,
        scroll: false,
        start: function(e) {
            $draggedImage = event.target;
            $drop.css({
                'display': 'block'
            });
        },
        helper: function(e) {
            return $('<img src="' + $(this).find('img').attr("src") + '" width="'+imgwidth+'">');
        },
        stop: function() {
            $draggedImage = null;
        },
        revert: true
    });
GomatoX
  • 400
  • 1
  • 3
  • 20
mydeve
  • 553
  • 1
  • 14
  • 39

1 Answers1

1

This might help you.

HTML

$("#draggable").draggable({
            snap: true
        });
        $("#draggable2").draggable({
            snap: ".ui-widget-header"
        });
        $("#draggable3").draggable({
            snap: ".ui-widget-header",
            snapMode: "outer"
        });
        $("#draggable4").draggable({
            grid: [20, 20]
        });
        $("#draggable5").draggable({
            grid: [80, 80]
        });
.draggable {
        width: 90px;
        height: 80px;
        padding: 5px;
        float: left;
        margin: 0 10px 10px 0;
        font-size: .9em;
    }
    .ui-widget-header p,
    .ui-widget-content p {
        margin: 0;
    }
    #snaptarget {
        height: 600px;
        width: 200px;
    }
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>

<table>
        <tr>
            <td>
                <div id="draggable" class="draggable ui-widget-content">
                    <p>Default (snap: true), snaps to all other draggable elements</p>
                </div>

                <div id="draggable2" class="draggable ui-widget-content">
                    <p>I only snap to the big box</p>
                </div>
            </td>
            <td>
                <div id="snaptarget" class="ui-widget-header">
                    <p>I'm a snap target</p>
                </div>
            </td>
            <td>
                <div id="draggable3" class="draggable ui-widget-content">
                    <p>I only snap to the outer edges of the big box</p>
                </div>

                <div id="draggable4" class="draggable ui-widget-content">
                    <p>I snap to a 20 x 20 grid</p>
                </div>

                <div id="draggable5" class="draggable ui-widget-content">
                    <p>I snap to a 80 x 80 grid</p>
                </div>
            </td>
        </tr>
    </table>

javascript

$(function() {
        $("#draggable").draggable({
            snap: true
        });
        $("#draggable2").draggable({
            snap: ".ui-widget-header"
        });
        $("#draggable3").draggable({
            snap: ".ui-widget-header",
            snapMode: "outer"
        });
        $("#draggable4").draggable({
            grid: [20, 20]
        });
        $("#draggable5").draggable({
            grid: [80, 80]
        });
    });

For Mobile you can use jquery ui touch punch it will help you and best solution is here

as per my knowledge jquery and jquery-ui is working awesome on 159.8.132.20/alldevice/.

Community
  • 1
  • 1
Shirish Patel
  • 874
  • 6
  • 14