Comments (10)
This was filed long ago at d3/d3#2096 but I have not gotten around to implementing it, largely because it adds complexity to some of the most complex code in D3 (because of inconsistency across browsers, the need to support multiple input modalities, and the inherently complex nature of interpreting sequences of input events as gestures). All that said I welcome this feature if the implementation can be made simple enough that it’s reasonable for me to maintain (i.e., it doesn’t introduce more bugs in the part of D3 that is already the most likely to receive bug reports). But the other difficulty is that if you add inertial dragging to d3-drag you’ll also want to implement it for d3-zoom.
from d3-drag.
I wanted this for the versor.js rotation of the globe.
It appears that you don't need to modify d3.drag internally.
During dragging, one can keep track of the gesture's last few positions, and on drag end, start a timer that will extend this movement during a certain (eased) time. One also has to take care of interruptions, such as when you start a new gesture during the extended movement.
To use it with versor rotation, you need a modified version of versor.js
that will compute the rotation (A) * (B^alpha), where:
- A is your final rotation at
dragended
- B is the delta rotation during the last few events of the drag gesture
- alpha is the eased time
The code could probably be nicer but hey.
https://bl.ocks.org/Fil/f48de8e9207799017093a169031adb02
from d3-drag.
Cool! That’s fun!
Side note: I am seeing a lot of flickering in that big lake in Russia, probably a winding order detection problem. I have also gotten reports of new winding order problems on Twitter and am concerned our change to decouple rotation from clipping has introduced winding order bugs.
from d3-drag.
I think the flickering on that big lake was always there — I remember seeing it more than once (but was pursuing something else so never stopped to create an issue). However I have it on this example with https://unpkg.com/[email protected] as well (just try with .rotate([107.1,-78.6,-162])
)
But it would be good to have precise reports. Moving this to d3-geo #121.
from d3-drag.
Thanks for investigating the unrelated d3-geo issue. Another question was whether it is a problem with the data file in this gist, vs. the latest world-atlas.
from d3-drag.
Yes! that json file was the culprit!
from d3-drag.
I have just published a d3-inertia module that solves this, with example(s).
from d3-drag.
@Fil That looks to be specific to rotating geographic projections, rather than generic 2D dragging. Maybe rename it to d3-geo-inertia, or d3-trackball or some such?
from d3-drag.
Your remark makes me realize that the geo helper should be called geo-something. However, the plugin is not meant to be specific to geo.
I just made a complicated planar example, it's clear we still need a helper for such a use case. Contributions welcome :)
from d3-drag.
Closing this issue due to inactivity. The discussion continues at https://github.com/Fil/d3-inertia/issues
from d3-drag.
Related Issues (20)
- Possible typo in README HOT 2
- What are the perposes of functions yesdrag and nodrag?
- Drag event on Chrome 72 HOT 3
- d3 mouseup event not firing HOT 1
- Drag Event Issue on Windows Chrome 74, related to solution for #47 HOT 1
- The default filter should return false if event.ctrlKey. HOT 5
- drag start event is don't send when Ctrl-key is press HOT 1
- drag.on("init") ? HOT 7
- Click event not firing if drag enables with simulation HOT 1
- Non-cancelable event HOT 3
- remove drag.container? HOT 1
- Use native events (*element*.dispatchEvent) instead of d3-dispatch? HOT 1
- remove dragEvent.on?
- d3.event is not available in version 6.1.1 HOT 1
- DragEvent missing event.currentTarget for arrow function node selection HOT 1
- Make event listeners non-passive. HOT 2
- d3.drag() causes error in testing mousedown event via jsdom HOT 4
- d3.pointer() could use event.touches[0] HOT 2
- Add event.currentTarget
- Support d3.drag in testing environments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-drag.