【发布时间】:2015-11-28 07:11:20
【问题描述】:
我正在尝试使用 JQuery 使 svg 元素可拖动(无 UI)我找到了这段代码 jsfiddle。我想创建类似jsfddle2 的东西。我想我不能在这样的 svg 元素上使用它。有什么制作方法吗?
function endMove() {
$(this).removeClass('movable');
}
function startMove() {
$('.movable').on('mousemove', function(event) {
var thisX = event.pageX - $(this).width() / 2,
thisY = event.pageY - $(this).height() / 2;
$('.movable').offset({
left: thisX,
top: thisY
});
});
}
$(document).ready(function() {
$("#testedCircle").on('mousedown', function() {
$(this).addClass('movable');
startMove();
}).on('mouseup', function() {
$(this).removeClass('movable');
endMove();
});
});
【问题讨论】:
标签: javascript jquery html css svg