I have been searching for hours to no avail in order to find out how to get this functionality out of my javascript/css/html code.
I have an image that I would like to rotate 90 degrees every time a button I created to rotate it is clicked.
for example:
click 1: 90 degree rotation
click 2: 180 degree rotation (in implementation I would assume 90 + 90)
and so on.
However, when I code it the way that I could assume would create this functionality it doesn't work. I can get the image to rotate once...then no more after the fact.
Here is the code I am working with.
The button:
<button id = "rotationRight" data-dojo-type="dijit.form.Button"
onclick = "rotateRight(90);" ></button>
Then here are some few different javascript functions I have tried to get this to work:
1
function rotateRight(deg){
var total_rot;
total_rot += deg;
deg = total_rot;
document.getElementById("drag").style.transform = "rotate("+ deg +"deg)"
if(total_rot == 360){
total_rot = 0;
}
}
2
function rotateRight(deg){
var x += deg ;
document.getElementById("drag").style.transform = "rotate("+ x +"deg)"
}
3
(currently the only one that does anything at all, but only rotates 90 once even on consecutive button clicks)
function rotateRight(deg){
document.getElementById("drag").style.transform = "rotate("+ deg +"deg)"
}
I am trying to achieve this functionality without Jquery. I am currently restricted to DOJO, javascript, CSS3 and HTML5. I feel like I am close, but I am not an experienced javascript developer and I am running out of ideas to try.