-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: FabricObject.prototype.set does not take effect #10031
Comments
Hmm... Do you want to set a default value? Or intercept the set? Use method a for setting a default value and method b for intercepting. import { FabricObject } from "fabric";
// a
FabricObject.ownDefaults.borderColor = "#000000"
// b
const lastSet = FabricObject.prototype.set;
FabricObject.prototype.set = function(k, v) {
console.log("before set", k, v);
const r = lastSet.call(this, k, v);
console.log("after set", k, v);
return r;
} |
You can't use the method set directly from the prototype in that way, you are calling it without context it doesn't have a THIS that make sense. |
Is it impossible to set custom props now? I was unsure if this was related to this issue or not. I have for example loadSVGFromURL(icon.svg, (_, svg) => {
var size = util.getRandomInt(24, 48)
svg.scaleToWidth(size)
svg.set({
left: util.getRandomInt(size / 2, maxWidth - size),
top: util.getRandomInt(size / 2, maxHeight - size),
id: icon.id,
origSize: size,
lockRotation: true,
lockScalingX: true,
lockScalingY: true,
hasControls: false
})
svg.setCoords()
canvas.add(svg)
}) But This worked in 5.x.x before |
it should be serialized, if it doesn't is a bug. |
When I made a reduced test case it worked fine lol So no bug, my fault gg |
Yeah that is usually the outcome. When you focus on reproducing in an isolated case you fix it. |
CheckList
Version
6.0.2
In What environments are you experiencing the problem?
No response
Node Version (if applicable)
None
Link To Reproduction
none
Steps To Reproduce
cornerStrokeColor: "#000000",
cornerColor: "#000000",
cornerStyle: "square",
transparentCorners: false,
cornerSize: 6, //边角大小
borderScaleFactor: 1,
borderColor: "#000000",
borderDashArray: [6],
padding: 5,
});
Expected Behavior
import { FabricObject } from "fabric";
FabricObject.prototype.set({
cornerStrokeColor: "#000000",
cornerColor: "#000000",
cornerStyle: "square",
transparentCorners: false,
cornerSize: 6, //边角大小
borderScaleFactor: 1,
borderColor: "#000000",
borderDashArray: [6],
padding: 5,
});
Actual Behavior
import { FabricObject } from "fabric";
FabricObject.prototype.set({
cornerStrokeColor: "#000000",
cornerColor: "#000000",
cornerStyle: "square",
transparentCorners: false,
cornerSize: 6, //边角大小
borderScaleFactor: 1,
borderColor: "#000000",
borderDashArray: [6],
padding: 5,
});
Error Message & Stack Trace
No response
The text was updated successfully, but these errors were encountered: