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

undefined is not a function (conflict with viewbox) #15

Open
Eonasdan opened this issue Oct 21, 2014 · 10 comments
Open

undefined is not a function (conflict with viewbox) #15

Eonasdan opened this issue Oct 21, 2014 · 10 comments
Labels

Comments

@Eonasdan
Copy link

I get undefined is not a function if I make the Snap() a div:

<div id="snappy"></div>

var $snappy = $("#snappy"),
    mapSnap = Snap("#snappy");

$snappy.html("");
Snap.load("http://huei90.github.io/snap.svg.zpd/lib/malaysia.svg", function (f) {
    mapSnap.append(f);
    mapSnap.zpd(); //<--- undefined is not a function
});

I was going to do a jsfiddle example but it won't load the image cross origin :(

@hueitan
Copy link
Owner

hueitan commented Oct 21, 2014

@Eonasdan
Hi, have you tried using <svg id="snappy"></svg> ?

@Eonasdan
Copy link
Author

@huei90

Ok, that works. Now I have a new issue. Using the scroll to zoom causes it to zoom in no matter which direction the scroll wheel is moved

@hueitan
Copy link
Owner

hueitan commented Oct 21, 2014

would you mind give me a demo link for this? thanks.

@Eonasdan
Copy link
Author

here's a self contained example: http://jonathanpeterson.com/svg.zpd.zip

it looks like this is an issue when using viewbox

@hueitan
Copy link
Owner

hueitan commented Oct 22, 2014

Ok then. Seems we have some conflicts with viewbox!

Thanks for report this 🍻

@hueitan hueitan added the bug label Oct 22, 2014
@hueitan hueitan changed the title undefined is not a function undefined is not a function (conflict with viewbox) Oct 22, 2014
@hueitan
Copy link
Owner

hueitan commented Jan 19, 2015

The viewBox and transform are conflicted!!!!

@tikiatua
Copy link
Collaborator

Please have a look at the beta branch to find an implementation that works with viewBox and transforms.. I am already using this implementation in a production setting - it is however far from complete and will probably need some manual code adjustments for your own setting.

I will try to do some further work on it at the begin of February.

@beatsforthemind
Copy link

I am also getting the "is not a function" error when calling .zpd(). Here is the code I am using to load the SVG with Snap() and how I am trying to call zpd(). I am looking to use the zoom() and zoomTo() functions with other functions. I do not have viewbox set. Can you let me know what might be going wrong here?

var s = Snap("#svg-container");
Snap.load("/path/to/my/svg/image.svg", function(data) {
    s.append(data);
});
s.zpd({
    zoom: false,
    pan: false,
    drag: false
});

@hueitan
Copy link
Owner

hueitan commented Jun 19, 2015

Try

var s = Snap("#svg-container");
Snap.load("/path/to/my/svg/image.svg", function(data) {
    s.append(data);
    s.zpd({
        zoom: false,
        pan: false,
        drag: false
    });
});

@beatsforthemind
Copy link

So, like the OP, I was calling Snap() on a div instead of an empty SVG element. I called Snap() on an empty SVG element using the code you posted and it's working how I want. Snap is appending the SVG data into the empty SVG element and zpd is not showing an error. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants