こんにちは、Raphael JS とプラグイン Raphael.Freetransform の使用を必要とする新しいプロジェクトに取り組んでいます。これまでのところ、プラグインは非常にうまく機能しており、非常にスムーズです。ただし、hideHandles() メソッドを使用することで、オブジェクトのドラッグを無効にしているようにも見えます。
これはバグですか、それとも設計上の選択ですか? 要素のハンドルを非表示にした後、要素のドラッグを再度有効にする必要がありますか? 設定してみました。Freetransform プラグインを使用せずに要素をドラッグ可能にするために特に必要なことはありますか?
これが私のコードです:
paper = new Raphael("container", "1680", "1005");
setA = paper.set();
circle = paper.circle(50, 50, 50);
circle.attr("fill", "#f00");
circle.attr("stroke", "#000");
notif = paper.circle(50, 50, 50);
notif.attr({ "fill": "r(0.5, 0.5) #fff-#f00", "fill-opacity": 1 });
lbl = paper.text(50, 50, "Label").attr({fill: '#000000'});
setA.push(circle);
setA.push(notif);
setA.push(lbl);
setA.click(function(){
console.log('clicked');
});
setA.hover(
// over //
function (){ console.log('over'); },
// out //
function (){ console.log('out'); }
);
setA.drag(
//onmove
function(){
console.log('object moving');
},
//onstart
function(){
console.log('start drag');
},
//onend
function(){
console.log('end drag');
}
);
ft = paper.freeTransform(setA, { drag: true, keepRatio: true, draw: [ 'bbox', 'circle' ] }, function(ft, events) { /*console.log(ft.attrs);*/ } );
$('#guideBtn').click(function(){
if ($('#guideBtn').text().indexOf('Show') > -1){ ft.showHandles(); $('#guideBtn').text('Hide Guide'); }
else{ ft.hideHandles(); $('#guideBtn').text('Show Guide'); }
});
freetransform ツールへのリンクは次のとおりです: https://github.com/ElbertF/Raphael.FreeTransform/
ご覧のとおり、ボタンのクリック ハンドラーを使用してハンドルの表示と非表示を切り替えているだけです。この後に追加の手順が必要ですか?
前もってありがとう、コナー