Custom Opacity

Change the opacity dynamically based on user interaction

Overview

Opacity effect will change the transparency of the element using CSS opacity property.

Syntax

Use data-tor-fx="<trigger>:@opacity(<start>;<end>) to change the opacity the element on given <trigger>. The <start> value represents the beginning opacity value, while the <end> is the finish value.

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 change the opacity of the element when scrolling the page, use data-tor-fx="scroll:@opacity(<amount>)".

opacity
opacity
<div data-tor-fx="scroll:@opacity(0;1)">opacity</div>
<div data-tor-fx="scroll:@opacity(1;0)">opacity</div>

mouse

To change the opacity of the element when moving the cursor over both x and y axis, use data-tor-fx="mouse:@opacity(<amount>)".

opacity
opacity
<div data-tor-fx="mouse:@opacity(0;1)__origin(start)">opacity</div>
<div data-tor-fx="mouse:@opacity(1;0)__origin(start)">opacity</div>

mouseX

To change the opacity of the element when moving the cursor over x axis, use data-tor-fx="mouseX:@opacity(<amount>)"

opacity
opacity
<div data-tor-fx="mouseX:@opacity(0;1)__origin(start)">opacity</div>
<div data-tor-fx="mouseX:@opacity(1;0)__origin(start)">opacity</div>

mouseY

To change the opacity of the element when moving the cursor over y axis, use data-tor-fx="mouseY:@opacity(<amount>)"

opacity
opacity
<div data-tor-fx="mouseY:@opacity(0;1)__origin(start)">opacity</div>
<div data-tor-fx="mouseY:@opacity(1;0)__origin(start)">opacity</div>