2

すべてドラッグおよびドロップ可能なタスクのリストがあります。それらすべてには、別のタスクがそれらの上にホバリングしているときにそれらが点灯することを確認するための「over」イベントハンドラーがあります。

これは私が望むように完全には機能していません。1つのタスクのドラッグを開始すると、マウスが実際にドラッグ可能なヘルパーの上にない場合を除いて、他のタスクが期待どおりに点灯しません(これは、カーソルを移動できるようにaxis ='y'を指定したために可能です)。ドラッグセッションを中断せずにヘルパーの左右)。

ドラッグしているタスクもドロップ可能であることが問題だと思ったので、ドラッグしたらドロップ可能性を無効にする必要があることを指定しました。

では、なぜドロップ可能なターゲット上にドラッグ可能なヘルパーがあるとオーバーイベントがトリガーされないのに、ドロップ可能なターゲット上にカーソルがあるとそのイベントがトリガーされるのでしょうか。

コードは次のとおりです。

$(mySubtasks).each(function(){
                    var _this = this;
                    $(_this).draggable({
                        axis: 'y',
                        containment: '#plannerTab',
                        disabled: true,
                        revert: 'invalid',
                        start: function(e, ui){
                            currentlyDragging = true;
                            $(_this).droppable('disable');
                            $('#messageArea').text('Currently dragging');
                            $(_this).css('position', 'absolute');
                        },
                        stop: function(e, ui){
                            currentlyDragging = false;
                            returnToSortableTasklist();
                            $(_this).css('position', 'relative');
                        }
                    });
                    $(_this).droppable({
                        accept: '.subtask',
                        disabled: true,
                        drop: function(e, ui){
                            setTimeout('currentlyDragging = false;', 1000);
                            alert('Dropped something legal on a subtask');
                            //Deactivate all draggable/droppable and reinstate sortable
                            returnToSortableTasklist();
                        },
                        over: function(e, ui){
                            $(this).addClass('dragdropTargetHover');
                            $(ui.helper).addClass('dragdropHelperHover');
                        },
                        out: function (e, ui){
                            $(this).removeClass('dragdropTargetHover');
                            $(ui.helper).removeClass('dragdropHelperHover');
                        }
                    });
4

2 に答える 2

1

そして、他の何かも干渉していました。ドラッグしたとき、ヘルパーは物理的にかなり小さかったです。ドラッグ可能の開始時に適切なサイズを設定して、ドラッグしているドロップ可能オブジェクトによって簡単に「検出」されるようにしました。

于 2010-07-17T09:32:23.293 に答える
1

I found that my "drop" even always triggered, even though my "over" event did not - specifically when I was dragging my object to another object that was close to the object being dragged. The suggestion of playing with the size of the helper did not work for me, but got me experimenting with the other attributes. I was surprised to find that when I increased my scrollSensibility, my problem went away. That is, because my draggable area was very large (horizontally), I had set scroll:true and scrollSensitivity:160. When I increased my scrollSensitivity to 400, my problem went away.

于 2012-02-03T00:01:01.380 に答える