私はいくつかのインタラクティブな UI を作成し、サイズ変更とマウス イベントに jQuery を使用しています。
すべての要素のイベントをバインドmouseOver
してクリックし、クリックを取得したら、クリック リスナーを削除します (サイズ変更可能なリスナーに干渉しないように)。
ここまでは問題なく動作し、選択した要素のサイズを変更できるようになりました。サイズ変更の開始は正常に機能しますが、その後でもmouseup
、要素のサイズ変更イベントは終了せず、マウスでサイズ変更されています。
どうしたの ?
物はここにあります。
http://parth.me/builderjs/index.html
主な部分は次のとおりです。
var
inspect = true, // to disable inspect
selected = null; // currently selected event
function clickhandler(e) {
console.log('click');
if (selected != null)return; // if some div is already selected, then return
if (e.which == 3)return; // if it was right click, return
selected = $(e.target); // selected = the element which received the click
inspect = false; // disable inspection
selected.addClass('selected'); // add SELECTED background + border
$(window).unbind('click', clickhandler); // remove the click listener
$('.selected').resizable(); // make the selected element resizable
}
$(window).bind('click', clickhandler); //bind the click event
Escキーは、選択を解除するようにバインドされています。