Questions tagged [snap.svg]

Snap.svg is a JavaScript library for creating and working with SVG.

Snap.svg is an open source library for creating and working with . It helps create interactive vector graphics with support for interactivity, animations and also allows working with existing svg with a simple JavaScript API.

Snap.svg was written by Dmitry Baranovskiy (author of Raphaël), and is designed specifically for making it easier to work with svg, and supporting features like masking, clipping, patterns, full gradients, groups, and more. The project is released by Adobe Systems.

References:

Demo

Drawing styling and adding animation to a circle.

var s = Snap(500,500);
var circle = s.circle(150, 150, 100);

circle.attr({
    fill: "#bada55",
    stroke: "#000",
});
circle.animate({r: 50}, 1000);
784 questions
4
votes
3 answers

Loop an animation with Snap.svg

Background: I'm using Snap.svg to render a circle, then animate its radius on hover. I've got that piece working with the code below. Problem: I'm trying to get a looping "pulse" effect once circleRadar is hovered on, which would involve…
Marcatectura
  • 1,721
  • 5
  • 30
  • 49
4
votes
2 answers

Select multiple paths with Snap.svg

Background: I'm using snap.svg to animate paths in an inline svg, and I'm trying to animate several paths in one function. Problem: using the code below, I'm only able to select a single path in one grab function. In the code below, I've used…
Marcatectura
  • 1,721
  • 5
  • 30
  • 49
4
votes
2 answers

How do you get the rotation value of an svg object with snap.svg?

So, I'm using snap.svg and I'd like to dynamically rotate an object over time. Something like this: function rotateObject() { myObject.rotation += value; } The problem is I don't know how to access the rotation values for my display objects (or…
Paul Mignard
  • 5,824
  • 6
  • 44
  • 60
4
votes
1 answer

Load SVG into a specific div with Snap SVG

What is the correct way to load an SVG file into a specific div using SnapSVG? Following the documentation I have this JS: var s = Snap(); Snap.load("fox.svg", function (f) { s.append(f.select("g#fox")); }); This loads the SVG just above the…
Sheixt
  • 2,546
  • 12
  • 36
  • 65
4
votes
1 answer

Snap.svg paper-object

I'm fiddling with Snap.svg. I don't want to sound really noobish but I don't get the next example in the API-docs; var f = paper.filter(Snap.filter.blur(5, 10)), c = paper.circle(10, 10, 10).attr({ filter: f }); I'm searching in the…
myradon
  • 421
  • 1
  • 4
  • 13
3
votes
1 answer

Remove and add elements from same position in snap svg group

I have snap svg group of 5 elements like; let canvas = Snap('#svg'); let myGroup = canvas.g(); myGroup.add(canvas.rect(100, 200, 110, 220).attr({fill: '#000'})); myGroup.add(canvas.circle(400, 400, 50).attr({fill: '#500'})); // want to remove this…
kapil sarwat
  • 97
  • 1
  • 8
3
votes
0 answers

Snap.select is null in React.js but not in vanilla JavaScript

I'm trying to get a script converted to React.js. This script is working without JS on a regular HTML page. However, when I try to use this in React, it's failing. Snap.select doesn't seem to work anymore. In my regular example I'm just using the…
Heis
  • 606
  • 5
  • 25
3
votes
1 answer

Javascript Snap.svg: Rotation animation goes the long way around at 270 degrees

I'm having an issue with snap.svg where whenever I animate a rotation between 269 and 270 degrees the whole thing spins around the entire circle instead of advancing a single degree. Here is a minimal code snippet that recreates the…
prismofeverything
  • 8,799
  • 8
  • 38
  • 53
3
votes
1 answer

How to use Snap.svg with Angular v4.0 (error: circle is not a function)

I don't know how to use Snap.svg with Angular v4.0, so I read this post. I tried the solution of @moeabdol (npm install ..., scripts: ..., declare ..., s.circle(...)), but I get the following error: ERROR TypeError: s.circle is not a…
3
votes
1 answer

Uncaught ReferenceError: eve is not defined

Snap svg is quite new to me, I have followed the setup mentioned in the https://github.com/adobe-webplatform/Snap.svg. (webpack setup) But I'm getting "Uncaught ReferenceError: eve is not defined". So I ended up using "const Snap =…
satheesh
  • 403
  • 5
  • 15
3
votes
2 answers

How to achieve overflow hidden with svg animation?

I am trying to animate a path within an svg. The path is of a squiggly line to look like a wave. What I am trying to do is have this path translate horizontally on a infinite loop to make it look as though the water is moving. You can see a…
h0bb5
  • 609
  • 1
  • 7
  • 22
3
votes
1 answer

Snap.svg in React - how to access the svg in a lifecycle method?

I have an svg map component which I want to update whenever the props change. Adding and subtract classes on some of the paths... that sort of thing. Snap.svg seemed to be the way to go. If someone knows a better way I'd like to hear it! So here's…
dwilbank
  • 2,470
  • 2
  • 26
  • 37
3
votes
1 answer

Snap.svg: How to pause/resume animation?

I have an example below that runs a circle around the edge of the SVG root drawing. I can stop and restart it with no problem. However, I would rather restart(resume) it at its last position, rather than resetting it back the start position. Is…
Francis Hemsher
  • 3,478
  • 2
  • 13
  • 15
3
votes
0 answers

Difference and Intersection of paths in SVG using Snap.path.intersection

I am trying to find the intersection between them, then using same result to get difference between first path and second one. I am trying this using Snap.path.intersection function in Snap.svg. here is the link to the…
mak
  • 31
  • 1
3
votes
3 answers

Black and white (not grayscale) filter in svg, ideally snap.svg

Edit 1: Rewrote question so it is clearer to understand. This one really split my mind. I would like to apply a filter to an image such that values over a certain threshold are displayed as completely white, and all the values that are equal or less…
Michael Seltenreich
  • 3,013
  • 2
  • 29
  • 55