Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update basic demo to include viewbox #92

Open
sdiemert opened this issue Jul 25, 2021 · 4 comments
Open

Update basic demo to include viewbox #92

sdiemert opened this issue Jul 25, 2021 · 4 comments

Comments

@sdiemert
Copy link

Great library! One suggestion for the README file.

Please include examples that setup up the viewbox. I spent about an hour trying to figure out why the most basic examples wouldn't integrate with my existing svgdotjs code. Turns out I wasn't setting the viewbox and I wouldn't have known to do this unless I dug into the issues on this repo.

A basic example might be:

// enables panZoom
var canvas = SVG()
  .addTo('#id')
  .size(1000, 1000)
  .viewbox('0 0 500 500')
  .panZoom()

// zoom programatically
canvas.zoom(lvl, point)

I understand that this will setup a 1000x1000 canvas and create 500x500 viewbox.

If you don't do something like this then one gets console errors like:

Error: <svg> attribute viewBox: Expected number...

Thank you!

@Fuzzyma
Copy link
Member

Fuzzyma commented Jul 26, 2021

Feel free to go ahead and create a pr which adds that to the Readme :)

@liweicheng00
Copy link

Thank you! This is really helpful.

@rainyspring
Copy link

me too

@BillyPurvis
Copy link

Super helpful, thank you @sdiemert!

notionparallax added a commit to notionparallax/svg.panzoom.js that referenced this issue Jan 12, 2023
This is in response to svgdotjs#92 , It's been a while and @sdiemert hasn't submitted a PR, so I thought I would.

I don't think it needs to be explained here, as the demo is trying to be super minimal. However, it might be worth explaining it elsewhere. Do you have any thoughts on where?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants