Set transform origin property X and Y coordinates struggling to set transform origin property from javascript for both axis.
so from javascript: object.style.transformOrigin = valueX valueY;
Unfortunately, it doesnt work... if i set 2 values it doesnt work.. if i set only 1 value, the valueX is changed only.
What i have done:
newClasses.style.transformOrigin = scaleOrigPoint + "px"; // sets only for valueX
newClasses.style.transformOrigin = (scaleOrigPoint + "px") + (scaleOrigPointY + "px"); // sets only for valueY
newClasses.style.transformOrigin = (scaleOrigPoint + "px") , (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = (scaleOrigPoint + "px") (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = [scaleOrigPoint]px; // doesnt set anything + ERROR
And many many other ways... Somethimes it changes the valueY only...
Question:
Is there a way to set bot valueX and valueY for transform origin property using javascript only?
Set transform origin property X and Y coordinates struggling to set transform origin property from javascript for both axis.
so from javascript: object.style.transformOrigin = valueX valueY;
Unfortunately, it doesnt work... if i set 2 values it doesnt work.. if i set only 1 value, the valueX is changed only.
What i have done:
newClasses.style.transformOrigin = scaleOrigPoint + "px"; // sets only for valueX
newClasses.style.transformOrigin = (scaleOrigPoint + "px") + (scaleOrigPointY + "px"); // sets only for valueY
newClasses.style.transformOrigin = (scaleOrigPoint + "px") , (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = (scaleOrigPoint + "px") (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = [scaleOrigPoint]px; // doesnt set anything + ERROR
And many many other ways... Somethimes it changes the valueY only...
Question:
Is there a way to set bot valueX and valueY for transform origin property using javascript only?
Share Improve this question edited May 23, 2017 at 12:15 CommunityBot 11 silver badge asked Jan 7, 2016 at 13:02 OzZieOzZie 5239 silver badges21 bronze badges 1-
Style properties set in JavaScript should be strings, as if written in a CSS stylesheet after the
<property>:
. – maxime.bochon Commented Jan 7, 2016 at 13:07
1 Answer
Reset to default 11Have you tried putting a space between them?
newClasses.style.transformOrigin = scaleOrigPoint + "px " + scaleOrigPointY + "px";