🤖 Merge PR #57493 fabric: Add currentTarget and currentSubTargets to fabric event by @ScottMorse

This commit is contained in:
Scott Morse
2021-12-02 16:50:05 -06:00
committed by GitHub
parent 8f46248ecb
commit ef1526a354
2 changed files with 6 additions and 0 deletions

View File

@@ -179,6 +179,8 @@ interface IEvent<E extends Event = Event> {
pointer?: Point | undefined;
absolutePointer?: Point | undefined;
transform?: { corner: string; original: Object; originX: string; originY: string; width: number } | undefined;
currentTarget?: Object | undefined;
currentSubTargets?: Object[] | undefined;
}
interface IFillOptions {

View File

@@ -7,6 +7,10 @@ function sample1() {
canvas.on('object:moving', (e: fabric.IEvent) => {
e.target.opacity = 0.5;
e.currentTarget.sendBackwards();
e.currentSubTargets.forEach((subTarget) => {
subTarget.bringToFront();
});
});
canvas.on('object:modified', (e: fabric.IEvent) => {
e.target.opacity = 1;