Answer the question
In order to leave comments, you need to log in
Is it possible to route an element using path in pure javascript?
There is a svg in which the path / route is built through path d
And for a day now I can’t understand how simple and without problems and convas to make it follow the element I need. I ask for help because there are no solutions on the network, either complex or incomprehensible
Example: There is a svg path curve, using svg.getTotalLength() I get its length 6000 and this is 100%
And for example I need to move the object by 20%, that is, the element must retreat by 1200 pixels along the way
The svg itself has a viewbox 0 0 1920 8900
and the resolution on which I'm testing is 1222
var svg = document.querySelector('.teams')
var x = svg.getPointAtLength(1200).x;
var y = svg.getPointAtLength(1200).y;
document.querySelector('.star').setAttribute('y', y)
document.querySelector('.star').setAttribute('x', x)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question