Optionalclipimport Moveable from "@moveable-next/vanilla";
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);
});
OptionalclipAdd clip guidelines in the horizontal direction.
import Moveable from "@moveable-next/vanilla";
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,
});
OptionalclippableWhether to clip the target.
import Moveable from "@moveable-next/vanilla";
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);
});
Optionalclip% Can be used instead of the absolute px (rect not possible)
import Moveable from "@moveable-next/vanilla";
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);
});
OptionalclipDistance value that can snap to clip guidelines.
import Moveable from "@moveable-next/vanilla";
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,
});
OptionalclipWhether the clip is bound to the target.
import Moveable from "@moveable-next/vanilla";
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);
});
OptionalclipAdd clip guidelines in the vertical direction.
import Moveable from "@moveable-next/vanilla";
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,
});
OptionalcustomYou can force the custom clipPath. (defaultClipPath < style < customClipPath < dragging clipPath)
import Moveable from "@moveable-next/vanilla";
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);
});
OptionaldefaultIf clippath is not set, the default value can be set. (defaultClipPath < style < customClipPath < dragging clipPath)
import Moveable from "@moveable-next/vanilla";
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);
});
OptionaldragWhen dragging the target, the clip also moves.
import Moveable from "@moveable-next/vanilla";
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);
});
OptionalkeepWhether to keep the ratio of size if your clipPath is 'inset', 'rect', 'ellipse' type
OptionalonWhen drag the clip area or controls, the clip event is called.
import Moveable from "@moveable-next/vanilla";
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);
});
OptionalonWhen drag end the clip area or controls, the clipEnd event is called.
import Moveable from "@moveable-next/vanilla";
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);
});
OptionalonWhen drag start the clip area or controls, the clipStart event is called.
import Moveable from "@moveable-next/vanilla";
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);
});
You can drag the clip by setting clipArea.