svgpan

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2021 License: MIT Imports: 5 Imported by: 0

README

go-svgpan

Pan and Zoom of SVG in your Go front-end app in browser.

This is port of JS svgpan. As of 2021-11-12, Google has just took a bunch of JS code and pasted it as raw const string. 🤦🏻‍♂️

Who is using this?
Troubleshooting

If you are getting following error

$ go get github.com/nikolaydubina/go-svgpan
package github.com/nikolaydubina/go-svgpan
    imports syscall/js: build constraints exclude all Go files in /usr/local/go/src/syscall/js

Try to download like

$ GOARCH=wasm GOOS=js go get github.com/nikolaydubina/go-svgpan

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SVGPanZoomer

type SVGPanZoomer struct {
	// contains filtered or unexported fields
}

SVGPanZoomer does zooming and panning of SVG using JS events. This is port of https://github.com/aleofreddi/svgpan Which is also as of 2021-09-19 inlined in https://github.com/google/pprof/blob/master/third_party/svgpan/svgpan.go

func NewSVGPanZoomer

func NewSVGPanZoomer(
	svgID string,
	rootID string,
	zoomScale float64,
) *SVGPanZoomer

func (*SVGPanZoomer) CenterBox

func (p *SVGPanZoomer) CenterBox(minx, miny, maxx, maxy float64) *SVGPanZoomer

CenterBox makes given bounding box in the center and fill the screen.

func (*SVGPanZoomer) Reset

func (p *SVGPanZoomer) Reset() *SVGPanZoomer

func (*SVGPanZoomer) ScaleAt

func (p *SVGPanZoomer) ScaleAt(z, x, y float64) *SVGPanZoomer

func (*SVGPanZoomer) SetRootTranslation

func (p *SVGPanZoomer) SetRootTranslation()

setRootTranslation updates translation matrix of root svg element

func (*SVGPanZoomer) SetupHandlers

func (p *SVGPanZoomer) SetupHandlers()

func (*SVGPanZoomer) Translate

func (p *SVGPanZoomer) Translate(dx, dy float64) *SVGPanZoomer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL