0
私は、ドラッグSVGグループのために、このコードを使用します。ドラッグSVGグループjqueryのUIを介し
$('svg g').draggable({
drag: function (event, ui) {
var position = ui.position;
var $shape = $(this);
var transform = $shape.attr("transform");
var translate = /translate\(\s*([^\s,)]+)[ ,]([^\s,)]+)/.exec(transform);
ُ$shape.attr("transform", "translate(" + (position.left + ($shape[0].getBoundingClientRect().width/2)) + "," + (position.top + ($shape[0].getBoundingClientRect().height/2)) + ")");
}
});
<svg><g class=" ui-draggable ui-draggable-handle" transform="translate(0,0)">
<path fill="#FBC596" stroke="#C35A05" stroke-width="1.5" d="M0,20L20,0l20,20L20,40L0,20z" />
<rect height="1.339713" width="16.172249" y="19.186603" x="12.105263" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#c35a05" fill="#fbc596" />
<rect transform="rotate(-90 20,20) " height="1.339713" width="16.172249" y="19.186603" x="12.105263" fill-opacity="null" stroke-opacity="null" stroke-width="1.5" stroke="#c35a05" fill="#fbc596" />
</g>
</svg>
が、SVGグループが成功位置にドラッグしていません!