Comments (1)
Hi there - I'm not sure exactly what you mean by "multiple instances," if you mean transforming multiple paths independently of each other, you can certainly do that.
To clarify, Flubber itself has no knowledge of <path>
elements and doesn't manipulate them, it only provides string values that you can apply to paths as needed.
For example, if you had a page with two path elements on it:
<path id="horse" />
<path id="zebra" />
and you wanted to turn one from a triangle into a horse, and the other from a triangle into a zebra, you could do something like:
// Your start/end path strings
var triangle = "M....Z",
horse = "M...Z",
zebra = "M....Z";
var triangleToHorse = flubber.interpolate(triangle, horse),
triangleToZebra = flubber.interpolate(triangle, zebra);
d3.select("#horse")
.transition()
.attrTween("d", function() { return triangleToHorse; });
d3.select("#zebra")
.transition()
.attrTween("d", function() { return triangleToZebra; });
Or, slightly more concise:
var triangle = "M....Z",
horse = "M...Z",
zebra = "M....Z";
d3.selectAll("#horse, #zebra")
.data([horse, zebra])
.transition()
.attrTween("d", function(animal) {
return flubber.interpolate(triangle, animal);
});
If this doesn't clear it up and you can post your full non-working code, I'll try to take a look.
from flubber.
Related Issues (20)
- Typescript typings
- Jest test fails: r.getTotalLength is not a function HOT 2
- Can we use flubber to animate from svg shape to path HOT 1
- Interpolate fills the shape HOT 2
- Using in Gatsby with IE11 HOT 1
- Animation typical doesn't work over time
- Error: 'svgPathProperties' is not exported HOT 1
- Broken in latest Chromium HOT 4
- output precision for path strings need not use 16 digits
- Reanimatedv2 HOT 1
- Porting to other languages HOT 2
- async API / non-blocking interpolation (using webworkers)
- Factor out `Number.isFinite` HOT 1
- Expose an API that outputs the compatible to/from path strings HOT 1
- Improving performance: aka To-Do for Performance HOT 1
- Flubber performs differently when loaded via webpack/babel. HOT 4
- Add flubber.align()?
- flubber with greensock HOT 3
- Support for open/unclosed polygons (polylines) HOT 3
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 flubber.