JavaScript Drag&选择正确的功能 [英] JavaScript Drag & Select functionality done right

查看:77
本文介绍了JavaScript Drag&选择正确的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力写一个拖累和放大器使用HTML& amp; JavaScript的。我的意思是会有一组具有任意绝对位置的物体。我希望能够将光标拖到它们布局的区域上。将其视为RTS策略(选择单位)或任何矢量图形编辑器(选择移动它们和编辑的对象)。

I'm trying to write a drag & select functionality using HTML & JavaScript. By that I mean that there will be a set of objects with arbitrary absolute positions. I want to be able drag the cursor over the area where they are laid out. Think of it as an RTS strategy (selecting units) or alternatively any vector graphics editor (selecting objects for moving them around and editing).

首先我知道在Google的前几页中出现的一些内容所以。因此,我绝不会要求为我搜索这些内容并在此处发布一些随机链接。

First of all I'm aware of things that come up in the first few pages of Google & SO. Therefore I'm by no means asking for googling those things for me and posting here some random links.

我能找到的大多数解决方案都是以某种方式有缺陷的。主要问题是抑制实际文本选择,这似乎违背了Web浏览器的本质。一些代码片段导致选择闪烁,我发现非常烦人。有些在所有主流浏览器中都表现不佳。

Most of the solutions that I was able to find are in some way flawed. The main problem is suppressing actual text selection, which seems kind of against the very nature of a web browser. Some of the code snippets cause selection twinkling that I find very annoying. Some don't behave well across all the major browsers.

我要求您提供实际使用或成功使用的代码/库的建议。

I'm asking for recommendations of code/libraries that you actually used, or seen successfully used.

第二件事是,我想真正了解抑制选择背后的JavaScript内部结构。如何在理论上做到这一点。是否有任何非hackish方式实现这一目标?

The second thing is, that I'd like to actually understand the internals of JavaScript behind suppressing selection. How should it be done in theory. Is there any non-hackish way of achieving that?

我能找到的最接近的是:
http://view.jquery.com/tags/ui/1.5b2/demos/ui.selectable。 html

The closest that I was able to find is this: http://view.jquery.com/tags/ui/1.5b2/demos/ui.selectable.html

然而它似乎与jQuery UI紧密结合,后者又需要jQuery 1.3.x而我真的很期待使用jQuery 1.5

However it seems to be tightly coupled with jQuery UI, which in turn requires jQuery 1.3.x whereas I was really looking forward to using jQuery 1.5

推荐答案

对不起我的英文。我正在使用这个库进行拖放操作,这很棒。不确定这是否是你需要的,但它可以提供帮助:

Sorry about my english. I'm using this library for drag/drop and it's great. Not sure if it's what you need, but it could help:

http://threedubmedia.com/code/event/drop/demo/selection

http://threedubmedia.com/code/event/drag

http://threedubmedia.com/code/event/drop

这篇关于JavaScript Drag&选择正确的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆