dragging items based on percentage to containment element

后端 未结 3 1651
长情又很酷
长情又很酷 2020-12-16 14:13

Here is what it looks like;

$( \"#box ul li\" ).draggable({
    helper: \"clone\"
});
$( \".item\" ).draggable({containment: \".door\"});

$( \".door\" ).dro         


        
3条回答
  •  我在风中等你
    2020-12-16 14:40

    I've found a solution;

    $( ".item" ).draggable({
      containment: ".door",
      stop: function( event, ui ) {
       $(this).css("left",parseInt($(this).css("left")) / ($(".door").width() / 100)+"%");
       $(this).css("top",parseInt($(this).css("top")) / ($(".door").height() / 100)+"%");
      }
    });
    

提交回复
热议问题