fil / d3-inertia Goto Github PK
View Code? Open in Web Editor NEWDragging stuff with inertia
License: Other
Dragging stuff with inertia
License: Other
The planets example sort of works, but it's not the end of the story:
it should be easy to unset inertia
currently the accumulation of movement is kept for a while even if we stop the mouse
https://beta.observablehq.com/@fil/using-d3-inertia-with-observable
it will help default rotation to take over in e.g.
https://bl.ocks.org/Fil/02e6d4c63ab52d202ca9d922b4b9000f
as per d3/d3-drag#27 (comment) ; a starting point might be https://bl.ocks.org/Fil/a034e32156b7b25ee9054c1bc50dc0ca without the fancy & random stuff
as per d3/d3-drag#27 (comment)
currently there is a mismatch between the d3-drag component of d3 and the standalone d3-drag
see https://bl.ocks.org/HarryStevens/8c9eba0905777a6ea778ebfc16f4d743
issue 1 is solved by adding if (inertia.timer) inertia.timer.stop();
http://blockbuilder.org/Fil/bf64676d0495518d98fffa21df46d0f0
and adapt the cursor
d3-inertia currently depends on versor ^0.1, which results in a download of versor 0.1.2. However, that version of versor incorrectly specifies its package.json
file, by specifying module
and jsnext:main
as src/versor.js
. No such file exists for that version; they should be pointing instead towards src/index.js
(or instead src/index.js
should have been src/versor.js
).
This actually does not matter for many cases, since d3-inertia's usage of versor under the hood uses the bundled versions in the dist
folder. However, some toolchains like Vite need this field to be correctly specified to avoid unnecessary bundling. Vite gives the following error when trying to run yarn start
:
node_modules/vite/dist/node/chunks/dep-63d4bd14.js:43786:10: error: [plugin: vite:dep-pre-bundle] Failed to resolve entry for package "versor". The package may have incorrect main/module/exports specified in its package.json:
I thought it would be as simple as requiring d3-inertia to use versor 0.2.0, but this did not work when I tried it out because versor 0.2.0 has type: module
in its package.json and thus the require
statement in d3-inertia's minified file fails. So I'm not sure what the best solution is.
If this issue occurs for anyone else, a temp fix for d3-inertia users is to use patch-package after just renaming versor 0.1.2's src/index.js
to src/versor.js
.
Btw, I've noticed one of the disorienting things about the versors globe rotation is that it can easily get turned sideways and upside down. I think maintaining a north-up orientation could improve the interaction. This example https://www.jasondavies.com/maps/zoom/ has a "north up" mode, but that's only for the programmatic jumps, not the rotation drag interaction. Do you think it's even possible to enforce a north-up view, or is it a conflicting restriction with the pan interaction?
two fingers gestures can send the script to infinity (or huge or NaN) velocities, which is definitely not good™
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.