d3.js - Javascript d3: Is there a way to progammatically stop dragging an item? -
When I click and drag an item, is there a way to stop it from dragging it tightly without leaving the mouse button? For example, if I drag an item into a certain limit box, can I drop the item to drag it?
I have suppressed a drag example from another user; Click to create a circle, then drag it to the blue box, look for it to work.
Here the concept is called X & amp; When an object is being dragged, then it is synced in The range here is based on a variable - x position, but can be expanded on the basis of a size surface area. The drag is being used for this event as a namespace, for an event for which D3 creates a dispatcher object (see D3 library code). It can be called by event name (for example) Or if you want to use the Attaching a mouseover event to 'border box' does not work because the object will be dragged between the mouse and the box. Perhaps there is also an alternative solution I have included another small red box (open the console to do this not to work) Source: d3.event , then trigger one of the two ways shown in the bottom as 'stop' event. The drawback is that Until drag event gets a mouseup, it throws an error, while the mouse is still being paused
// drag lewier var drag = D3. Beavier Define drag (.on) ("drag", drumvov); Function dragmove (d) {// if event.x exceeds one limit, trigger "dragend" (d3.event.x> 200) {// using D3 drag.dragend (); // or using jquery drag.trigger ("dragend"); } Var x = d3.event.x; Var y = d 3.event.y; D3.select (this) .attr ("conversion", "translation (" + + "," + y + ")"); }
drag.on ("eventName", functionToDo) drag.eventName ();
JQuery , it can be used by using a trigger:
Drag.trigger ("dragend")
Comments
Post a Comment