简体   繁体   中英

Snap.SVG attaching SVG elements

I'm trying to insert an SVG using snap.svg, to a page and then have it rotate and expand slightly. I'm using brackets at the moment as some local live preview thing, and the problem I'm having is twofold; I managed to get it in place about half an hour ago and then broke it somehow and now I don't know how to get it back, and the syntax for snap.svg is condensed enough to make it kind of iffy to read, and the documentation isn't very good, so I'm unable to work out how exactly I do what I want to do. I gave search a go, but the callback method I found doesn't seem to be working. Can anybody help?

<!DOCTYPE html>
    <html>


    <body>
    <script src="snap.svg-min.js"></script>

    <script type="text/javascript">
        var paper = Snap(500,500),
        Snap.load('ringing-phone.svg', function (phone) {
        phone.selectAll("path[fill='#ff0000']").attr({fill: "#00ff00"});
        var g = phone.select("g");
    });
        </script>



    </body>


    </html>

You have a naughty comma after the var paper line, it should be a semicolon, as you aren't defining a variable on the next line.

var paper = Snap(500,500); //<-- this semicolon
Snap.load('ringing-phone.svg', ....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM