There are a lot of errors in your code, but, in particular, I think that you complicate it too much using the material on the left / right. Just use a positive or negative numeric value to indicate the amount of rotation:
<p class="worldMenuPosition " data-spaces="-1" id="box1">Rotate one space left</p>
<p class="worldMenuPosition" data-spaces="1" id="box2">Rotate 1 space right</p>
<p class="worldMenuPosition " data-spaces="-2" id="box1">Rotate two spaces left</p>
<p class="worldMenuPosition" data-spaces="2" id="box2">Rotate 2 spaces right</p>
, :
$(document).ready(function () {
var currentRotation = -35,
rotationIncrement = 35;
$(".worldMenuPosition").click(function () {
var spaces = $(this).data("spaces");
rotateToDirection(spaces * rotationIncrement);
});
function rotateToDirection(deg) {
currentRotation += deg;
positionBoxes();
}
function rotateTo(deg, box) {
var bplate = ["translate(-50%,-50%) rotate(", deg,
"deg) translateY(-200px) rotate(", -5, "deg)"];
$(box).css({
"transform": bplate.join("")
});
}
function positionBoxes() {
$(".worldSection").each(function (index, element) {
rotateTo(currentRotation + (index * rotationIncrement), element);
});
}
positionBoxes();
});
http://jsfiddle.net/TMuD5/9/
, .
, "" , data-position 4 , " ". " " 35 data-position 4 , , " "
box1 - -70, -35, 0, 35, 70, ...
box2 - 0, 70, 140, 210, 280, ...
box3 - -70, 35, 140, 245, 350, ...
box4 - 0, 140, 280, 420, 560, ...
, , " ", -35 ( ), 0 , 35 .. 35 .
"" , , 35 . .