Comments (4)
Closed with 525ce54, which always checks for browser API first before falling back to svg-path-properties.
from flubber.
This does seem like a transpilation issue of some kind - I can reproduce the issue with CRA but if I copy the flubber repo into src/
instead, and import it directly, e.g.:
import { interpolate } from "./flubber/index.js"
I can get the desired effect. I'm not sure where exactly the transpiler is going awry, I'll try to look into it more later.
from flubber.
I think there are two related issues at play here:
-
The particular path strings you included get very different results when measuring them with the browser's native SVG
.getPointAtLength
vs. with the svg-path-properties library. If I force Flubber to use the browser's measurement, it looks fine. svg-path-properties is approximating the curves in such a way that the calculated points are far enough off the mark to produce this weird result with this particular shape. -
Flubber includes the following block:
if (typeof module !== "undefined" && module.exports) {
return svgPathProperties(d);
} else {
var svg = window.document.createElementNS("http://www.w3.org/2000/svg", "svg"),
path = window.document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttributeNS(null, "d", d);
return path;
}
the purpose of which is to use the browser's native SVG methods when running in a browser, and otherwise to use the svg-path-properties library to measure the path string's length and points along it when running in Node.
Something about how Webpack wraps modules into its bundle is causing Flubber to think it's not in a browser and execute that block instead of skipping it, presumably module.exports
is getting shimmed in somehow.
The ideal solution for this would be for me to produce a different build for the browser
field in package.json that doesn't use svg-path-properties at all, and then maybe Webpack would rely on that instead. But in the meantime, it seems like the fix here would be to update the Webpack config in such a way that it actually bundles the ES6 modules directly rather than using the rolled up flubber.min.js
.
from flubber.
Thanks for the fix!
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
- Multiple instances of flubber.js HOT 1
- Improving performance: aka To-Do for Performance HOT 1
- 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.