Please help. I think this is very simple but I could not figure out how to do it.

请帮忙。我认为这很简单,但我无法弄清楚如何做到这一点。

I've successfully created draggable elements and they are working perfectly as expected. I can drag and drop them without any errors.

我已成功创建了可拖动元素,并且它们按预期完美运行。我可以毫无错误地拖放它们。

The problem is this:

问题是这样的:

While I'm dragging (not yet dropping it) a box (which is a div), I have two copies of that box on my screen: one is the box on its original position, and the other is the box that drags along with my mouse.

当我拖动(尚未丢弃)一个盒子(这是一个div)时,我在屏幕上有两个那个盒子的副本:一个是原始位置的盒子,另一个是拖动的盒子我的老鼠

What I want to achieve is this:

我想要实现的是:

I want the original box to disappear as soon as I start dragging. The only box that I want to appear on the screen is the one that drags along with my mouse.

我希望原始框在我开始拖动时消失。我想要在屏幕上显示的唯一一个框是与鼠标一起拖动的框。

I'm using CodeIgniter as my framework, then javascript for my drag and drop effects. I'm not using jquery because I have very limited knowledge of it.

我使用CodeIgniter作为我的框架,然后使用javascript作为我的拖放效果。我没有使用jquery,因为我对它的知识非常有限。

Thanks.

1 个解决方案

#1


1

Why do this need to use clone, I can't understand.I have write a DEMO on the jsfiddle with native javascript that maybe U need.

为什么这需要使用克隆,我无法理解。我已经在jsfiddle上编写了一个可能需要的原生javascript的DEMO。

ZxDrugProto._druging = function(e) {
    this.top = e.clientY - this.preY + this.top;
    this.left = e.clientX - this.preX + this.left;
    this.dom.style.top = this.top+'px';
    this.dom.style.left = this.left+'px';
    this.preY = e.clientY;
    this.preX = e.clientX;
}

更多相关文章

  1. Android 可拖动的进度条:SeekBar之简单使用
  2. Android 可拖动进度条:SeekBar之自定义进度条
  3. Android自定义View-----上下拖动布局--SlideContentLayout
  4. Android从零开搞系列:自定义View(15)仿天天美剧拖动卡片的效果(下)
  5. 拖动层的javasvript代码 十行代码即可写出兼容版拖动层
  6. javascript实现拖动层效果代码(许愿墙)

随机推荐

  1. Android 本地推送消息到通知栏 Notificat
  2. Mono登录界面记住密码的控件
  3. android 源码编译同步的小问题
  4. 【android】时间选择器
  5. Android 简单音乐播放器(破烂版,后续更新)
  6. 解决Android studio 启动报错java.lang.R
  7. Android DHT11驱动
  8. android 读取 icon
  9. Android Studio报错:Ignoring unknown pa
  10. android 如何把新建项目的那个 android a