首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在IE中不工作的拖放

在IE中不工作的拖放
EN

Stack Overflow用户
提问于 2014-03-04 18:45:25
回答 2查看 1.1K关注 0票数 2

我有一个被拖放到SVG画布上的单位列表。你可以看到它,这里

为此操作定义和配置单元的方式如下:

代码语言:javascript
复制
var units = html.document.querySelectorAll('ul.units li');
units.onDragStart.listen(_onDragStart);
units.onDragEnd.listen(_onDragEnd);

void _onDragStart(html.MouseEvent e) {
    _dragSource = e.target as html.LIElement;
    _dragSource.classes.add('moving');
    e.dataTransfer.effectAllowed = 'move';

    if (isFirefox) {
      e.dataTransfer.setData('text/plain', 'Required for Firefox!');
    }
}

void _onDragEnd(html.MouseEvent e) {
    _dragSource.classes.remove('moving');
}

SVG画布有以下定义:

代码语言:javascript
复制
canvas = html.document.querySelector(canvas_id);
canvas.onDragOver.listen(_onDragOver);
canvas.onDrop.listen(_onDrop);

void _onDragOver(html.MouseEvent e) {
    e.preventDefault();
}

void _onDrop(html.MouseEvent e) {
    e.preventDefault();
    html.Element dropTarget = e.target;
    if (dropTarget == canvas && _dragSource != null && _dragSource.classes.contains('moving')) {
      String operatorId = 'operator_${opNumber}';
      var mouseCoordinates = getRelativeMouseCoordinates(e);
      operators[operatorId] = addOperator(operatorId, _dragSource.dataset['unit-type'], mouseCoordinates['x'], mouseCoordinates['y']);
      opNumber += 1;
    }
}

除了Windows上的IE和Safari之外,这对所有浏览器都有效。问题是我甚至没有收到任何错误或异常消息。你们有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-05 01:25:44

IE11和更早版本不支持SVG元素的HTML5拖放。我制作了一个简单的科德芬,您可以使用它在不同的浏览器上进行测试。

如果要支持SVG元素上的拖放,则需要进行手动命中测试。如果你感兴趣,你可以看看drag-drop.dart。这是我的一个库,支持跨浏览器拖放SVG。文档是不存在的,但是您可以查看示例和测试来了解如何使用它。

票数 2
EN

Stack Overflow用户

发布于 2014-03-07 01:08:05

你试过这个图书馆了吗?

https://github.com/marcojakob/dart-html5-dnd

它有助于使用dnd,而不必担心每个特定浏览器的实现。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22180314

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档