Comments (16)
In typescript-angular project I added svgjs in my component as import ,
how can ı add svg.panzoom.js ?
from svg.panzoom.js.
I got it to work as follow:
declare var SVG: any;
import 'svgjs';
import 'svg.panzoom.js';
Thanks for your help. @dnldsht didn't work for me the first time because I was declaring after the imports.
from svg.panzoom.js.
npm install svg.js svg.panzoom.js
?
from svg.panzoom.js.
yes, but how to use it with svg.js?
for example:
import svg from 'svg.js';
and then what?
from svg.panzoom.js.
as far as i know import
is no node specific syntax.
In order to have working plugins you need SVG.js as a global. When you use webpack you can shim the modules in thsi case.
The other way is just to keep SVG.js as global by using
SVG = require('svg.js')
require('svg.panzoom.js')
from svg.panzoom.js.
i was referring to the import in es2015. It will need babel, but thanks
from svg.panzoom.js.
Experience shows that imports like this do not create a global. That's why the require syntax is needed
from svg.panzoom.js.
@fthsvk I've added them in my angular-cli file like this
"scripts": [
"../node_modules/svg.js/dist/svg.min.js",
"../node_modules/svg.panzoom.js/dist/svg.panzoom.min.js"
],
and referenced them in components
import etc,
...
declare var SVG: any;
export class MyComponent implements OnInit {
...
ngOnInit() {
SVG('myId').panZoom()
}
...
}
from svg.panzoom.js.
With es6, I do like this and they work just fine:
import SVG from 'svg.js';
import 'svg.draggy.js';
import 'svg.connectable.js';
import 'svg.foreignobject.js';
import 'svg.panzoom.js';
from svg.panzoom.js.
Any idea how to use this with Ionic ES6? None of the approach above work. When I do .panZoom() it tells me is not found although I have already imported it.
import 'svg.js';
import 'svg.panzoom.js';
declare var SVG: any;
when I do console.log(SVG), SVG is there but .panZoom
from svg.panzoom.js.
Please look at the post before yours. It seems like import SVG from 'svg.js'
works just fine while yours don't.
If this also does not work for you, add SVG to the global space with global. SVG = SVG
. You have to do that before importing any other plug in
from svg.panzoom.js.
@Fuzzyma thanks for your quick reply.
I tried your suggestion and it's still not working. I approached it multiple ways:
const globalAny:any = global;
import SVG from 'svg.js'
globalAny.SVG = SVG;
import 'svg.panzoom.js';
or
const globalAny:any = global;
globalAny.SVG = SVG;
import SVG from 'svg.js'
import 'svg.panzoom.js';
and
const windowAny:any = window;
import SVG from 'svg.js'
windowAny.SVG = SVG;
import 'svg.panzoom.js';
or
const windowAny:any = window;
windowAny.SVG = SVG;
import SVG from 'svg.js'
import 'svg.panzoom.js';
all approaches result in: Property 'panZoom' does not exist on type 'Doc'.
I also tried without the Global
from svg.panzoom.js.
Is only typescript complaining about that or is the code complaining (when transpiled to js). We do not have any extra typings for the plugins so typescript does not know anything about the methods a plugin added
If really the code complains, you can Try SVG = require(...)
(note the missing var)
from svg.panzoom.js.
I am also getting Property 'panZoom' does not exist on type 'Doc'.
By following @jfbourne 's post above:
I got error SVG(...).attr(...).size(...).panZoom is not a function
Seems panZoom was not added to the svg.Doc.
My TS code for the svg panzoom:
this.draw = SVG(ParentDom).attr('id','SVG2D').size(
"100%",
"100%"
).panZoom({zoomMin: 0.5, zoomMax: 20});
from svg.panzoom.js.
@Rubinhuang9239 please use matching versions. There is a version for svg.js v2.x and one for svg.js v3.x
from svg.panzoom.js.
@Fuzzyma thanks!
Lol, that's my bad! I made it work now.
from svg.panzoom.js.
Related Issues (20)
- Question: Apply CSS to and svg while zooming HOT 4
- Feature request: transformer key HOT 1
- Select text and copy HOT 3
- .panZoom is not a function on ES6 modules HOT 5
- low accuracy HOT 5
- [FeatureRequest] Programmatically fit an element into the view HOT 2
- Pan working but not zoom HOT 1
- Panning does not work if I use the margins property HOT 49
- Get current zoom factor HOT 2
- SVG not defined error HOT 18
- Cannot use in SVG files (no type=module) HOT 1
- Request: add event detail to panZoom HOT 4
- New feature: keyboard navigation HOT 3
- Update basic demo to include viewbox HOT 4
- When oneFingerPan is true clicks on SVG elements are not working anymore HOT 13
- Is it possible to obtain the real coordinates within the SVG if the user has zoomed in/out? HOT 3
- pinchZoom: Add option to change the zoom factor HOT 1
- need the zoomend event,is there another way to achieve it?
- Please add a method to pan svg programmatically HOT 7
- Pan / Zoom is blocking <input> in foreignObject HOT 2
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 svg.panzoom.js.