Custom Rotate

Rotate the element over x, y and z axis based on user interaction

Overview

Rotate effect will turn the element using CSS rotateX, rotateY and rotateZ property.

Syntax

Use data-tor="<trigger>:@transform=<rotateX|rotateY|rotateZ>(<start>;<end>) to rotate the element over x or y axis. The <start> value represents the beginning rotate value, while the <end> is the finish value.

transform shortcut

You can use @T= shortcut instead of writing full @transform= to make your code shorter.

Examples

The <mouse> examples uses {method: start} for more natural behavior. Try to move the cursor from the screen top-left corner into the bottom-right, the left edge to the right one, and from the top edge into the bottom.

scroll

To rotate the element when scrolling the page, use data-tor="scroll:@transform=<rotateX|rotateY|rotateZ>(<amount>)".

rotateX
rotateY
rotateY
<div data-tor="mouse:@transform=rotateX(0deg;90deg)">rotateX</div>
<div data-tor="mouse:@transform=rotateY(0deg;90deg)">rotateY</div>
<div data-tor="mouse:@transform=rotateZ(0deg;90deg)">rotateY</div>

mouse

To rotate the element when moving the cursor over both x and y axis, use data-tor="mouse:@transform=rotateX(<amount>)" for horizontal rotate and data-tor="mouse:@transform=rotateY(<amount>)" for vertical rotate.

rotateX
rotateY
rotateY
<div data-tor="mouse:@transform=rotateX(0deg;90deg, {method: start})">rotateX</div>
<div data-tor="mouse:@transform=rotateY(0deg;90deg, {method: start})">rotateY</div>
<div data-tor="mouse:@transform=rotateZ(0deg;90deg, {method: start})">rotateY</div>

mouseX

To rotate the element when moving the cursor over x axis, use data-tor="mouseX:@transform=<rotateX|rotateY|rotateZ>(<amount>)"

rotateX
rotateY
rotateY
<div data-tor="mouseX:@transform=rotateX(0deg;90deg, {method: start})">rotateX</div>
<div data-tor="mouseX:@transform=rotateY(0deg;90deg, {method: start})">rotateY</div>
<div data-tor="mouseX:@transform=rotateZ(0deg;90deg, {method: start})">rotateY</div>

mouseY

To rotate the element when moving the cursor over y axis, use data-tor="mouseY:@transform=<rotateX|rotateY|rotateZ>(<amount>)"

rotateX
rotateY
rotateY
<div data-tor="mouseY:@transform=rotateX(0deg;90deg, {method: start})">rotateX</div>
<div data-tor="mouseY:@transform=rotateY(0deg;90deg, {method: start})">rotateY</div>
<div data-tor="mouseY:@transform=rotateZ(0deg;90deg, {method: start})">rotateY</div>