English 中文(简体)
相当于j Query.draggable()的土著 j印
原标题:Native javascript equivalent to jQuery.draggable()

Is there a native javascript code equivalent to jQuery s draggable? I don t need all the features but

  1. being able to drag a modal window from a handle.
  2. on start and on end events as I need to make an overlay layer while dragging to prevent the mouse being upon the iframe inside the modal window.
  3. there will be only one draggable item on the document.
最佳回答

使用<代码>dragstart/code>和dragend。 假设与分子×和坐标有关的模式的位置。

问题回答

这里有“超声望5”透镜,但因为没有人会这样说,老的浏览器都不支持它,因此,我要说,你在“Qu”中找到了很好的解决办法。

采用超文本5方法,这种方法似乎比舱面更清洁:

<div draggable="true"
  ondragstart="event.dataTransfer.setData( text/plain ,  12345 )">
drag me
</div>

<div ondragover="return false;" 
  ondrop="this.innerHTML=event.dataTransfer.getData( text/plain )">
drop on me
</div>

尽管问题表明土著Java语,但Im神要回答,因为@Moe Sweet评论说,j Query was<>>。

Drag and drop is a particular event chain. It s not obscenely difficult, but it can be challenging.

Simply put, drag and drop is the following steps/events:

  1. Mouse pressed down, dragging is enabled
  2. Mouse is moved, dragging continues
  3. Mouse is let up, dragging is disabled

简单的解决办法是利用这些活动:mousedown,mousemovemouseup

$(anElement).mousedown(foodown);

function foodown(){
  $(window).mousemove(foomove).mouseup(fooup);
  //stuff
}

function foomove(){
  //stuff
}

function fooup(){
  //stuff
  $(window).unbind( mousemove , foomove).unbind( mouseup , fooup);
}

值得注意的一个要点是,<代码>/Mousedown之后的事件必须受window的约束,这样,如果这些改动在被搁置时留下了原来的要素,就将发生。

守则中的“足迹”部分是,如果你需要检查该元素的 screen子和 screen的 screen子,并适当移动。 申请在<代码>mousemove期间确实是必要的。 当摩擦胜诉者申请<条码>/代码>或<条码>更改时,该活动即为活动。

还有一个类似的问题,即,我贴上了一部 j子的法典。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.