【问题标题】:Restrict Draggable To be Dropped Only if it is Completely Inside the Droppable?仅当它完全在 Droppable 内时才限制 Draggable 被丢弃?
【发布时间】:2014-08-25 07:45:16
【问题描述】:

看看这个演示,让我知道如何强制 jQuery UI 仅当可拖动对象完全位于可放置对象内时才将可拖动对象放置在可放置对象内?

$(function() {
        $( "#draggable" ).draggable();
        $( "#droppable" ).droppable({
            drop: function( event, ui ) {
                $( this )
                    .find( "p" )
                        .html( "Dropped!" );
            }
        });
    });

【问题讨论】:

    标签: jquery jquery-ui jquery-ui-draggable jquery-ui-droppable


    【解决方案1】:

    使用公差选项进行拟合。 将脚本更改为

    $( "#droppable" ).droppable({tolerance: "fit", drop: function( event, ui ) {
        $( this ).find( "p" ).html( "Dropped!" );
        }
    

    【讨论】:

      猜你喜欢
      • 2011-02-27
      • 1970-01-01
      • 1970-01-01
      • 2014-01-25
      • 1970-01-01
      • 1970-01-01
      • 2011-03-05
      • 1970-01-01
      • 2020-02-29
      相关资源
      最近更新 更多