这是我的代码:
<div id="box" style="border:1px solid red;height:100px;width:150px;position:relative;background:#eee">
<div id="head" style="background:black">drag me</div>
<div id="content" contenteditable=true style="border-bottom:1px solid red;height:70px;margin-bottom:5px;"> edit it </div>
<input id="ok" type="button" value="ok"/>
<input id="cancel" type="button" value="cancel"/>
</div>
Run Code Online (Sandbox Code Playgroud)
并且脚本是:
$('#box').draggable()
Run Code Online (Sandbox Code Playgroud)
演示在这里:http://jsfiddle.net/VRxZe/
谢谢
如何制作它以便我可以在页面上的主体上进行mousedown,然后向上或向下拖动页面,就像在PDF中一样?
基本上我希望能够上下拖动整个页面,任何想法如何做到这一点?我不想使用jQuery UI做任何事情.
有人可以在这方面向我推动正确的方向.我想将NSString从表格单元格拖动到NSView,然后根据该字符串执行某些操作,但拖放的东西让我的头部旋转了一下.无论如何知道一个可以解释所有这一切的直接教程.
谢谢
我希望能够上下拖动分隔线以在固定页面高度上调整分隔线上方和下方的div.这些div可能在一张表中,尽管它们不一定是.
简而言之,我希望能够模仿jsFiddle网站上发生的事情,尽管我只需要垂直调整大小.jsFiddle使用过mooTools,但我想用jQuery来做.
一个重要的复杂因素:在动态构建之前,我不会知道除法器上方div的大小,所以我不能只是设置绝对定位.
前进的最佳方式是什么?我有一种感觉,如果我不问,我只会重新发明轮子:)
[顺便说一句:有几个类似名称的问题与不起作用的jsFiddle示例有关(例如,这个).
到目前为止我用过这个:
$('.rsh').draggable({
axis:'y',
drag: function (event, ui) {
var offsettop = ui.offset.top;
$(this).prev().css({
height: offsettop
});
});
Run Code Online (Sandbox Code Playgroud)
不用说,它还没有正常工作.
我希望能够区分是否拖动或单击了影片剪辑,并相应地执行不同的功能.问题是startMrag由MOUSE_DOWN启动,而MOUSE_UP启动stopDrag,每次都会触发CLICK事件.我想要做的是,在click事件的条件中,说出"if dragging == true {do something}"之类的内容
我想我可以在mouse_up或mouse_down函数中设置一个标志,但问题是mouse_down与鼠标点击同时发生.我需要能够在实际的stopDrag()函数中设置标志.我已经看到了一个涉及设置超时的解决方案 - 我想避免这种情况.有任何想法吗?
我有一个拖放类应用程序.您可以在哪里选择图像并将其拖动到屏幕上的任何位置!我遇到的问题是,当你移动到另一个视图时,当我返回时,所有图像都重置到中心.例如,如果我按下按钮将我带到屏幕2,我刚刚做的所有"拖动"图像将移回中心.
这只有在我启用了AUTOLAYOUT时才会发生:(我的所有图像都是从中心开始的,所以我猜它的自动布局......
有任何想法吗 ?!
这是我的拖动图像代码的示例.
- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer {
CGPoint translation = [recognizer translationInView:self.view];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
}
Run Code Online (Sandbox Code Playgroud) 我是D3.js的新手,我想使用图形布局.我有这个演示设置了一个非常简单的图形,遵循D3内置的力导向布局.
我想要做的是能够关闭图形布局算法(例如,当用户按下空格时),然后仍然能够拖动节点,并在以后重新打开力导向布局.
现在我设置它以在击中空间时停止力导向布局:
d3.select("body")
.on("keydown", function() {
if (d3.event.keyCode == 32) {
if (forceActive) {force.stop();} else {force.resume();}
}
});
Run Code Online (Sandbox Code Playgroud)
问题是每次拖动节点时都会重新启动force-layout.我已经将它缩小到(基本上)节点上的调用方法绑定到强制布局的拖动方法.
即这段链接代码:
var node = svg.selectAll(".node")
.data(graph.nodes)
.enter().append("circle")
...
.call(force.drag);
Run Code Online (Sandbox Code Playgroud)
我想我可能要做两件事:
我想知道以前是否已经完成这项工作,以及如何做到(根本不会使用我的猜测,如何做到这一点).
以下是我正在处理的D3.js可视化示例:

这里,灰色圆圈是SVG容器.我想限制绿色气泡拖动到灰色圆圈边界.
我找到了这个例子,我在我的代码中使用它,但是我有两个错误:
Uncaught TypeError: Cannot read property 'apply' of undefined // points to d3.v3.min.js:3
Uncaught TypeError: Cannot read property 'each' of undefined // points to line X marked in the code below
Run Code Online (Sandbox Code Playgroud)
似乎我无法使用.call(drag)Force Layout.
我该如何工作?的jsfiddle
JS:
var data = {
name: "layout",
children: [
{name: "AxisLayout", size: 6725},
{name: "BundledEdgeRouter", size: 3727},
{name: "CircleLayout", size: 9317},
{name: "CirclePackingLayout", "size": 12003},
{name: "DendrogramLayout", "size": 4853},
{name: "ForceDirectedLayout", "size": 8411},
{name: "IcicleTreeLayout", "size": …Run Code Online (Sandbox Code Playgroud) 它不会崩溃,我在这里提到的所有异常只能在Visual Studio的Output窗口中看到.这是Dragging:
WPF 的实现:
<StackPanel Orientation="Vertical"
MouseDown="DragShortcut"
x:Name="Shortcut">
<Image Source="{Binding Icon}"/>
<Label Content="{Binding ShortcutLabel}"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
cs代码:
private void DragShortcut(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed)
return;
var dataObject = new DataObject(DataFormats.FileDrop, new[] { Options.DragDropOptions.ShortcutPath });
DragDrop.DoDragDrop(Shortcut, dataObject, DragDropEffects.Copy);
}
Run Code Online (Sandbox Code Playgroud)
一切似乎按预期工作,但每次我在桌面或资源管理器窗口上拖动东西时,我在Visual Studio的"输出"窗口中收到以下消息:
...
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type …Run Code Online (Sandbox Code Playgroud) 我想绘制一个有4个不等长度的边和能够拖动它的顶点的形状.当我拖动顶点时,连接到它的侧面应相应调整大小.
我在SO上发现了另一个问题但是提出的解决方案适用于Rectangles而我希望开发一种梯形形状的解决方案,如下图所示:

我目前的代码:
property var selection: undefined
Image {
id: image1
anchors.fill: parent
source: "1.jpg"
MouseArea {
anchors.fill: parent
onClicked: {
if(!selection)
selection = selectionComponent.createObject(parent, {"x": parent.width / 4, "y": parent.height / 4, "width": parent.width / 2, "height": parent.width / 2})
}
}
}
Component {
id: selectionComponent
Rectangle {
id: selComp
border {
width: 2
color: "steelblue"
}
color: "#354682B4"
property int rulersSize: 18
MouseArea { // drag mouse area
anchors.fill: parent
drag{ …Run Code Online (Sandbox Code Playgroud) drag ×10
javascript ×3
jquery ×3
d3.js ×2
autolayout ×1
c# ×1
comexception ×1
events ×1
flash ×1
force-layout ×1
nstableview ×1
nsview ×1
qml ×1
qt ×1
qtquick2 ×1
resize ×1
scroll ×1
shape ×1
svg ×1
uiimage ×1
wpf ×1