拖动并突出显示 [英] Dragging and highlighting

查看:102
本文介绍了拖动并突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个



请注意,对于对称性,您可能希望淡入 上的节点dragstop


In this jsfiddle user is supposed to be able to drag a node, and while he/she is dragging, only that node and his neighbors, and links between them, should be highlighted.

I thought I have a good solution, but a problem was reported if the user drags node to the boundary, and in such case there is undesired behavior - all nodes suddenly are highlighted:

(ERROR IS WHEN DRAGGED NODE HITS THE WALL)

This is due to the fact that mouse pointer went away from the node, but user is still keeping the mouse buttons, and still expects only selected node to be highlighted, and others to remain grayed.

Can this be fixed? Can I redesign events so that this situation is cured?

解决方案

What you want is to fade the non-neighboring nodes while one of them is being dragged, not only on mouseover:

force.drag().on('drag', fade(.1));

Working example: http://jsfiddle.net/h358K/

Note that for symmetry, you might want to fade in the nodes on dragstop.

这篇关于拖动并突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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