Custom Translate

Translate the element in horizontal and vertical direction based on user interaction

Overview

Translate effect will move the element using CSS translateX and translateY property.

Syntax

Use data-tor-fx="<trigger>:@transform.<translateX|translateY|translateZ>(<start>;<end>) to translate the element over x or y axis. The <start> value represents the beginning translate value, while the <end> is the finish value. You can use any supported CSS translate unit.

Examples

The <mouse> examples uses __origin(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 translate the element when scrolling the page, use data-tor-fx="scroll:@transform.<translateX|translateY|translateZ>(<amount>)".

translateX
translateY
<div data-tor-fx="mouse:@transform.translateX(0px;20px)">translateX</div>
<div data-tor-fx="mouse:@transform.translateY(0px;50px)">translateY</div>

mouse

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

translateX
translateY
<div data-tor-fx="mouse:@transform.translateX(0px;20px)__origin(start)">translateX</div>
<div data-tor-fx="mouse:@transform.translateY(0px;50px)__origin(start)">translateY</div>

mouseX

To translate the element when moving the cursor over x axis, use data-tor-fx="mouseX:@transform.<translateX|translateY|translateZ>(<amount>)"

translateX
translateY
<div data-tor-fx="mouseX:@transform.translateX(0px;20px)__origin(start)">translateX</div>
<div data-tor-fx="mouseX:@transform.translateY(0px;50px)__origin(start)">translateY</div>

mouseY

To translate the element when moving the cursor over y axis, use data-tor-fx="mouseY:@transform.<translateX|translateY|translateZ>(<amount>)"

translateX
translateY
<div data-tor-fx="mouseY:@transform.translateX(0px;20px)__origin(start)">translateX</div>
<div data-tor-fx="mouseY:@transform.translateY(0px;50px)__origin(start)">translateY</div>