Whether to clip the target.
Members
dragWithClip
When dragging the target, the clip also moves. (default: true)
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
defaultClipPath
If clippath is not set, the default value can be set. (defaultClipPath < style < customClipPath < dragging clipPath)
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
customClipPath
You can force the custom clipPath. (defaultClipPath < style < customClipPath < dragging clipPath)
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
clipVerticalGuidelines
- Source:
- Default Value:
- 0
Add clip guidelines in the vertical direction.
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
clipVerticalGuidelines: [0, 100, 200],
clipHorizontalGuidelines: [0, 100, 200],
clipSnapThreshold: 5,
});
clipTargetBounds
- Source:
- Default Value:
- false
Whether the clip is bound to the target.
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
clipTargetBounds: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
clipSnapThreshold
- Source:
- Default Value:
- 5
istance value that can snap to clip guidelines.
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
clipVerticalGuidelines: [0, 100, 200],
clipHorizontalGuidelines: [0, 100, 200],
clipSnapThreshold: 5,
});
clipRelative
% Can be used instead of the absolute px (`rect` not possible) (default: false)
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
clippable
Whether to clip the target. (default: false)
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
clipHorizontalGuidelines
- Source:
- Default Value:
- []
Add clip guidelines in the horizontal direction.
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
clipVerticalGuidelines: [0, 100, 200],
clipHorizontalGuidelines: [0, 100, 200],
clipSnapThreshold: 5,
});
clipArea
- Source:
- Default Value:
- false
You can drag the clip by setting clipArea.
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
Type Definitions
ClippableOptions
Properties:
clippable
optional
Default Value: false
clippable?:
boolean | ClippableOptions
Whether to clip the target.
keepRatio
optional
Default Value: false
keepRatio?:
boolean
Whether to keep the ratio of size if your clipPath is 'inset', 'rect', 'ellipse' type
customClipPath
optional
customClipPath?:
string
You can force the custom clipPath. (defaultClipPath < style < customClipPath < dragging clipPath)
defaultClipPath
optional
defaultClipPath?:
string
If clippath is not set, the default value can be set. (defaultClipPath < style < customClipPath < dragging clipPath)
clipRelative
optional
Default Value: false
clipRelative?:
boolean
% Can be used instead of the absolute px (`rect` not possible)
dragWithClip
optional
Default Value: true
dragWithClip?:
boolean
When dragging the target, the clip also moves.
clipArea
optional
Default Value: false
clipArea?:
boolean
You can drag the clip by setting clipArea.
clipTargetBounds
optional
Default Value: false
clipTargetBounds?:
boolean
Whether the clip is bound to the target.
clipVerticalGuidelines
optional
Default Value: []
clipVerticalGuidelines?:
Array<string | number>
Add clip guidelines in the vertical direction.
clipHorizontalGuidelines
optional
Default Value: []
clipHorizontalGuidelines?:
Array<string | number>
Add clip guidelines in the horizontal direction.
clipSnapThreshold
optional
Default Value: 5
clipSnapThreshold?:
number
Distance value that can snap to clip guidelines.
Type:
- TSInterface
OnClip
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
OnClipEnd
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
OnClipStart
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
Events
clip
When drag the clip area or controls, the `clip` event is called.
Type | Description |
---|---|
Moveable.Clippable.OnClip | Parameters for the `clip` event |
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
clipEnd
When drag end the clip area or controls, the `clipEnd` event is called.
Type | Description |
---|---|
Moveable.Clippable.OnClipEnd | Parameters for the `clipEnd` event |
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});
clipStart
When drag start the clip area or controls, the `clipStart` event is called.
Type | Description |
---|---|
Moveable.Clippable.OnClipStart | Parameters for the `clipStart` event |
Example
import Moveable from "moveable";
const moveable = new Moveable(document.body, {
clippable: true,
defaultClipPath: "inset",
customClipPath: "",
clipRelative: false,
clipArea: false,
dragWithClip: true,
});
moveable.on("clipStart", e => {
console.log(e);
}).on("clip", e => {
if (e.clipType === "rect") {
e.target.style.clip = e.clipStyle;
} else {
e.target.style.clipPath = e.clipStyle;
}
}).on("clipEnd", e => {
console.log(e);
});