Manipulate layers to create X ray effect
xLayers class provides a way to manipulate multiple layers one on another to create interesting effects as x-rays, peeling, etc.
It also provides a mouse interaction for resizing/moving layers with available restrictions to which layers can be modified and which actions can be performed
This class also provides basic animation for resizing layers, configurable by animation steps and time interval between steps
Contents
Download
Example codes
var x = new xLayers("id", {
//width of layer
width: "auto",
//height of layer
height: "auto",
//minimal width
minWidth: 10,
//minimal height
minHeight: 10,
//animation interval
interval: 100,
//animation steps
steps: 10,
//enable mouse interaction
enableMouse: true,
//px to offset for mouse resizing cursor
offset: 10,
//allow to edit directions using mouse
//East, West, North, South
allowedActions: ["up", "down", "left", "right", "move"],
//do not allow to edit these layers using mouse
disallowLayers: []
});
Examples in action
- html_example.html - demonstrates layers with HTML
- animate_example.html - demonstrates basic animation
- peeling_example.html - demonstrates peeling example
- xray_example.html - demonstrates xray example
Example video
Video of class example app:
Method list
Constructor
| Method name | new xLayers(elem, config) |
| Description | Create xLayers instance with provided configuration |
| Input parameters | string or element elem - element which is a container to all layers: json config - json with configuration options:
|
Get Layers
| Method name | getLayers() |
| Description | Get object with layer ID's as keys and layer HTML elements as values |
Resize layer
| Method name | resize(el, side, value) |
| Description | Resize layer from specified side for provided relative value |
| Input parameters | int or element el - layer to resize. It is possible to provide ID or element itself as a layer string side - side from which to resize. For sides use values as 'up', 'down', 'left', 'right' int value - relative value by how much to resize. For example, value -10, shortens layer from specified side by 10 pixels |
Animate resizing
| Method name | animate(el, side, value, steps) |
| Description | Resize layer from specified side for provided value as animation |
| Input parameters | int or element el - layer to resize. It is possible to provide ID or element itself as a layer string side - side from which to resize. For sides use values as 'up', 'down', 'left', 'right' int value - relative value by how much to resize. For example, value -10, shortens layer from specified side by 10 pixels int steps - animation steps to perform |
Latest changes
None for nowYou may also be interested in:
Powered by BlogAlike.com










