Rotatable

Moveable. Rotatable

Source:
Rotatable indicates whether the target can be rotated.

Members

throttleRotate

Source:
throttle of angle(degree) when rotate.
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body);

moveable.throttleRotate = 1;

rotationPosition

Source:
You can specify the position of the rotation. (default: "top")
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body, {
  rotationPosition: "top",
});

moveable.rotationPosition = "bottom"

rotatable

Source:
Whether or not target can be rotated. (default: false)
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body);

moveable.rotatable = true;

Methods

request(eopt, e.deltaRotateopt, e.rotateopt) → {Moveable.Requester}

Source:
Name Type Description
e? object the Resizable's request parameter
Properties
Name Type Default Description
deltaRotate? number 0 delta number of rotation
rotate? number 0 absolute number of moveable's rotation
Example
// Instantly Request (requestStart - request - requestEnd)
moveable.request("rotatable", { deltaRotate: 10 }, true);

* moveable.request("rotatable", { rotate: 10 }, true);

// requestStart
const requester = moveable.request("rotatable");

// request
requester.request({ deltaRotate: 10 });
requester.request({ deltaRotate: 10 });
requester.request({ deltaRotate: 10 });

requester.request({ rotate: 10 });
requester.request({ rotate: 20 });
requester.request({ rotate: 30 });

// requestEnd
requester.requestEnd();
Returns:
Moveable Requester
Type
Moveable.Requester

Type Definitions

OnBeforeRotate

Source:
Properties:
currentTarget: MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
moveable: MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
target: HTMLElement | SVGElement
The Moveable's target
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.
isFirstDrag: number
Whether this is the first drag in the drag event
datas: IObject<any>
Objects that can send information to the following events.
inputEvent: any
The mouse or touch input event that is invoking the moveable event
stopAble: () => void
Stop the currently working able.
stopDrag: () => void
Calling `stopDrag` in a drag-related event ends the drag.
isTrusted: boolean
Whether the event did not occur externally
beforeRotation: number
The rotation degree before transform is applied before snap and throttle and format
rotation: number
The rotation degree before snap and throttle and format
absoluteRotation: number
The client rotation degree before snap and throttle and format
setRotation: (nextRotation: number) => void
You can set the value of `rotation`.
Parameters for the `beforeRotate` event
Type:
  • TSInterface

OnBeforeRotateGroup

Source:
Properties:
targets: Array<HTMLElement | SVGElement>
The rotating targets
Parameters for the `beforeRotateGroup` event
Type:
  • TSInterface

OnRotate

Source:
Properties:
style: Record<string, string>
You can get the style you can get from the event.
cssText: string
You can get it as a cssText that you can get from that event.
transform: string
a target's next transform string value.
afterTransform: string
A transform obtained by the simultaneous occurrence of other events in the current event
drag: OnDrag
transform events causes a `drag` event. In some events, there may be no value.
currentTarget: MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
moveable: MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
target: HTMLElement | SVGElement
The Moveable's target
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.
isFirstDrag: number
Whether this is the first drag in the drag event
datas: IObject<any>
Objects that can send information to the following events.
inputEvent: any
The mouse or touch input event that is invoking the moveable event
stopAble: () => void
Stop the currently working able.
stopDrag: () => void
Calling `stopDrag` in a drag-related event ends the drag.
isTrusted: boolean
Whether the event did not occur externally
beforeDist: number
The distance of rotation degree before transform is applied
beforeDelta: number
The delta of rotation degree before transform is applied
beforeRotate: number
The now rotation degree before transform is applied
beforeRotation: number
The now rotation degree before transform is applied
dist: number
The distance of rotation degree
delta: number
The delta of rotation degree
rotate: number
The now rotation degree
rotation: number
The now rotation degree
absoluteDist: number
The distance of client rotation degree
absoluteDelta: number
The delta of client rotation degree
absoluteRotate: number
The now client rotation degree
absoluteRotation: number
The now client rotation degree
isPinch: boolean
Whether or not it is being pinched.
resize optional
resize?: OnResize
rotate causes a `resize` event.
Parameters for the `rotate` event
Type:
  • TSInterface

OnRotateEnd

Source:
Properties:
currentTarget: MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
moveable: MoveableManagerInterface<Record<string, any>, Record<string, any>>
The Moveable instance
target: HTMLElement | SVGElement
The Moveable's target
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.
isFirstDrag: number
Whether this is the first drag in the drag event
datas: IObject<any>
Objects that can send information to the following events.
inputEvent: any
The mouse or touch input event that is invoking the moveable event
stopAble: () => void
Stop the currently working able.
stopDrag: () => void
Calling `stopDrag` in a drag-related event ends the drag.
isTrusted: boolean
Whether the event did not occur externally
lastEvent: any | undefined
This is the last dragged event. No, if you haven't dragged.
isDrag: boolean
Whether this moved
isDouble: boolean
Whether it is double-click
Type:
  • TSInterface

OnRotateGroup

Source:
Properties:
targets: Array<HTMLElement | SVGElement>
The rotating targets
events: OnRotate[]
Each `rotate` event on the targets
set
set: (rotation: number) => any
You can set the group's rotation.
setGroupRotation: (rotation: number) => any
You can set the group's rotation.
Parameters for the `rotateGroup` event
Type:
  • TSInterface

OnRotateGroupEnd

Source:
Properties:
targets: Array<HTMLElement | SVGElement>
The rotate finished targets
events: OnRotateEnd[]
Each `rotateEnd` event on the targets
Type:
  • TSInterface

OnRotateGroupStart

Source:
Properties:
targets: Array<HTMLElement | SVGElement>
targets to rotate
events: OnRotateStart[]
Each `rotateStart` event on the targets
Type:
  • TSInterface

OnRotateStart

Source:
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
target: HTMLElement | SVGElement
The Moveable's target
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.
isFirstDrag: number
Whether this is the first drag in the drag event
datas: IObject<any>
Objects that can send information to the following events.
inputEvent: any
The mouse or touch input event that is invoking the moveable event
stopAble: () => void
Stop the currently working able.
stopDrag: () => void
Calling `stopDrag` in a drag-related event ends the drag.
isTrusted: boolean
Whether the event did not occur externally
set
set: (rotate: number) => void
You can set the start rotate value.
Default Value: target's transformOrigin
setFixedDirection: (fixedDirection: number[]) => void
Set a fixed direction to rotate.
Default Value: target's transformOrigin
setFixedPosition: (fixedPosition: number[]) => void
Set a fixed position to rotate.
dragStart: OnDragStart | false
rotate causes a `dragStart` event.
resizeStart: OnResizeStart | false
rotate causes a `resizeStart` event.
Type:
  • TSInterface

RotatableOptions

Source:
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.
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.
rotatable optional
Default Value: false
rotatable?: boolean | RotatableOptions
Whether or not target can be rotated.
rotationPosition optional
Default Value: "top"
rotationPosition?: RotationPosition | RotationPosition[]
You can specify the position of the rotation.
Default Value: 0
rotateAroundControls?: boolean
You can rotate around direction controls. Either `rotateAroundControls` or `displayAroundControls` can be used.
Default Value: null
resolveAblesWithRotatable?: Record<string, LineDirection[]> | null | undefined
Sets the control that will cause resize along with rotate. (Only Single Target, Only resizable, Beta)
throttleRotate optional
Default Value: 0
throttleRotate?: number
throttle of angle(degree) when rotate.
rotationTarget optional
Default Value: null
rotationTarget?: MoveableRefType | ArrayFormat<MoveableRefType> | false
Set additional rotationTargets.
Type:
  • TSInterface

RotatableRequestParam

Source:
Properties:
isInstant optional
isInstant?: boolean
Run the request instantly. (requestStart, request, requestEnd happen at the same time)
[key: string]: any
deltaRotate optional
deltaRotate?: number
delta number of rotation
rotate optional
rotate?: number
absolute number of moveable's rotation
the Rotatable's request parameter
Type:
  • TSInterface

Events

rotate

Source:
When rotating, the rotate event is called.
Type Description
Moveable.Rotatable.OnRotate Parameters for the rotate event
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body, { rotatable: true });
moveable.on("rotate", ({ target, transform, dist }) => {
    target.style.transform = transform;
});

rotateEnd

Source:
When the rotate finishes, the rotateEnd event is called.
Type Description
Moveable.Rotatable.OnRotateEnd Parameters for the rotateEnd event
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body, { rotatable: true });
moveable.on("rotateEnd", ({ target, isDrag }) => {
    console.log(target, isDrag);
});

rotateGroup

Source:
When the group rotate, the `rotateGroup` event is called.
Type Description
Moveable.Rotatable.OnRotateGroup Parameters for the `rotateGroup` event
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body, {
    target: [].slice.call(document.querySelectorAll(".target")),
    rotatable: true
});
moveable.on("rotateGroup", ({ targets, events }) => {
    console.log("onRotateGroup", targets);
    events.forEach(ev => {
        const target = ev.target;
        // ev.drag is a drag event that occurs when the group rotate.
        const left = ev.drag.beforeDist[0];
        const top = ev.drag.beforeDist[1];
        const deg = ev.beforeDist;
    });
});

rotateGroupEnd

Source:
When the group rotate finishes, the `rotateGroupEnd` event is called.
Type Description
Moveable.Rotatable.OnRotateGroupEnd Parameters for the `rotateGroupEnd` event
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body, {
    target: [].slice.call(document.querySelectorAll(".target")),
    rotatable: true
});
moveable.on("rotateGroupEnd", ({ targets, isDrag }) => {
    console.log("onRotateGroupEnd", targets, isDrag);
});

rotateGroupStart

Source:
When the group rotate starts, the `rotateGroupStart` event is called.
Type Description
Moveable.Rotatable.OnRotateGroupStart Parameters for the `rotateGroupStart` event
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body, {
    target: [].slice.call(document.querySelectorAll(".target")),
    rotatable: true
});
moveable.on("rotateGroupStart", ({ targets }) => {
    console.log("onRotateGroupStart", targets);
});

rotateStart

Source:
When the rotate starts, the rotateStart event is called.
Type Description
Moveable.Rotatable.OnRotateStart Parameters for the rotateStart event
Example
import Moveable from "moveable";

const moveable = new Moveable(document.body, { rotatable: true });
moveable.on("rotateStart", ({ target }) => {
    console.log(target);
});