Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set x / y with dollar sign programmatically via javascript

ANSWERED

Hello,

 

I'm trying to set the relative x to a previous element programmatically. Normally in SVG we can use

$+10

to set the x relative.

 

But when I do this in javascript I get the following error:

Unhandled TypeError: Argument at index 0 is not a Number

How can I achieve this?

 

Thank you in advance.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Using the $ in this way for javascript is not supported.

 

Have you thought about referencing the coordinates of the preceding element (that $ would be referring to) and use those in your calculation.

 

 

import document from "document";

var objectOne = document.getElementById("ObjectOne");
var objectTwo = document.getElementById("ObjectTwo");

objectTwo.x = objectOne.x+10;
objectTwo.y = objectOne.y+25;

 

 

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

Using the $ in this way for javascript is not supported.

 

Have you thought about referencing the coordinates of the preceding element (that $ would be referring to) and use those in your calculation.

 

 

import document from "document";

var objectOne = document.getElementById("ObjectOne");
var objectTwo = document.getElementById("ObjectTwo");

objectTwo.x = objectOne.x+10;
objectTwo.y = objectOne.y+25;

 

 

Best Answer
0 Votes