Skip to content

Update basic demo to include viewbox #92

@sdiemert

Description

@sdiemert

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions