Warpable indicates whether the target can be warped(distorted, bented).
Members
warpable
Whether or not target can be warped. (default: false)
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body);
moveable.warpable = true;
renderDirections
Set directions to show the control box. (default: ["n", "nw", "ne", "s", "se", "sw", "e", "w"])
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
warpable: true,
renderDirections: ["n", "nw", "ne", "s", "se", "sw", "e", "w"],
});
moveable.renderDirections = ["nw", "ne", "sw", "se"];
Type Definitions
OnWarp
Properties:
currentTarget:
MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
moveable:
MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
clientX:
number
The horizontal coordinate within the application's client area at which the event occurred.
clientY:
number
The vertical coordinate within the application's client area at which the event occurred.
multiply:
(matrix1: number[], matrix2: number[], n?: number) => number[]
Multiply function that can multiply previous matrix by warp matrix
Type:
- TSInterface
OnWarpEnd
Properties:
currentTarget:
MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
moveable:
MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
clientX:
number
The horizontal coordinate within the application's client area at which the event occurred.
clientY:
number
The vertical coordinate within the application's client area at which the event occurred.
Type:
- TSInterface
OnWarpStart
Properties:
Default Value: transform of target's inline style
setTransform:
(transform: string | string[], transformIndex?: number) => void
Set your original transform.
`transformIndex` is the sequence of functions used in the event.
If you use `setTransform`, you don't need to use `set` function.
Default Value: index with that property in transform or last
setTransformIndex:
(transformIndex: number) => void
`transformIndex` is the sequence of functions used in the event.
currentTarget:
MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
moveable:
MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
clientX:
number
The horizontal coordinate within the application's client area at which the event occurred.
clientY:
number
The vertical coordinate within the application's client area at which the event occurred.
Type:
- TSInterface
WarpableOptions
Properties:
renderDirections
optional
Default Value: false if rotatable, ["n", "nw", "ne", "s", "se", "sw", "e", "w"] otherwise
renderDirections?:
boolean | string[]
Set directions to show the control box.
edge
optional
Default Value: false
edge?:
boolean | Array<LineDirection>
Whether to scale and resize through edge lines.
You can use "n", "w", "s", "e" in LineDirection array.
displayAroundControls
optional
Since:
0.44.0
Story Example: options--options-control-padding
Default Value: false
displayAroundControls?:
boolean
You can expand the area around the control.
Either `rotateAroundControls` or `displayAroundControls` can be used.
You can set the area through the `controlPadding` value.
Type:
- TSInterface
Events
warp
When warping, the warp event is called.
Type | Description |
---|---|
Moveable.Warpable.OnWarp | Parameters for the warp event |
Example
import Moveable from "moveable";
let matrix = [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
];
const moveable = new Moveable(document.body, { warpable: true });
moveable.on("warp", ({ target, transform, delta, multiply }) => {
// target.style.transform = transform;
matrix = multiply(matrix, delta);
target.style.transform = `matrix3d(${matrix.join(",")})`;
});
warpEnd
When the warp finishes, the warpEnd event is called.
Type | Description |
---|---|
Moveable.Warpable.OnWarpEnd | Parameters for the warpEnd event |
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, { warpable: true });
moveable.on("warpEnd", ({ target, isDrag }) => {
console.log(target, isDrag);
});
warpStart
When the warp starts, the warpStart event is called.
Type | Description |
---|---|
Moveable.Warpable.OnWarpStart | Parameters for the warpStart event |
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, { warpable: true });
moveable.on("warpStart", ({ target }) => {
console.log(target);
});