Comments (4)
When doing the first version of the control api, that is the one that is still available today, there were 2 way to define controls properties. On the object and with styleOverrides.
The reasoning was that we would see what was the usage and we would change depending on feedback.
At the moment duplicating the setting on the object and on the control and then deciding which one has the priority didn't look good ( it doesn't to me also today ).
You can create a custom render function, let's say you want to render a circle, pass a render option to your control:
acc[`newPoint${index}`] = new fabric.Control({
positionHandler: this.newPointPolygonPositionHandler.bind(this, index),
mouseUpHandler: this.newPointAnchorWrapper(index),
actionName: "newPointPolygon",
cursorStyle: "copy",
render: function(
ctx: CanvasRenderingContext2D,
left: number,
top: number,
styleOverride: ControlRenderingStyleOverride | undefined,
fabricObject,
) {
renderCircleControl.call(
this,
ctx,
left,
top,
styleOverride: {
cornerColor: 'specialColorYouWant'
}
fabricObject,
);
}
})
this is a way to do it.
You can also define this control as a subclass of the standard control and keep it as a preconfigured class
from fabric.js.
thank you @asturur ! That's exactly what I needed.
Additional question, is it possible to catch right click event on fabric.Control
? I've only managed to catch left click (using the mouseUpHandler
)
from fabric.js.
ah. If it doesn't fire no, but i would agree it would be sort of normal to have it?
It probably doesn't work because if the click is not left with let go the whole function and we stop checking.
Maybe you can use _findTargetCorner on the activeObject on a generic mouseUp/mouseDown on the canvas and call the control mouseUp handler manually?
This could be something we could support out of the box, you should open a separate feature request for it
from fabric.js.
Thank you, separate feature request filed. I think this issue can be closed.
from fabric.js.
Related Issues (20)
- TypeError: Cannot read properties of undefined (reading 'getRetinaScaling') - How to Resolve?
- [Feature]: i want to create a drawing tool which work like the attached video HOT 2
- [Bug]: [Group Flip] Scaling Flip Group then Scaling Flip its child object, the child object behavior is wrong HOT 4
- [Feature Request]: Gradient not apply to underline,overline and linethrough on Text. HOT 4
- [Bug]: shadow appears on the upper side, and the underline displays on the backside of a Textbox when objectcaching is false
- is there any way select an transparent polygon or a fabric object with out using the perPixelTargetFind ?
- i cant select a fabric object when its color is transparent with out use perPixelTargetFind , i cant use perPixelTargetFind in my project because of the so many polygon objects aligned closely so i cant use that , is there any other way to select the transparent object ?
- [Bug]: My canvas like a drawing page here im facing an issue that i draw a polyline in down and them i want show the preview of the line when mouse move and the preview showing fine but when i zoom with mouse wheel the preview getting disappear , then mouse wheel down the canvas zoom back to default state the preview showing fine only when the canvas zoom is greater than default state the polyline preview getting disappearing , i cant solve the issue please give me any solution for that
- [Bug]: Main website SSL issue HOT 3
- [Bug]: Abort signal not propagated from loadFromJSON() to objects in Group HOT 2
- [Bug]: can not use fabricjs with web-worker HOT 7
- he controlls point is not valid, i can`t scale the size by the controlls points HOT 2
- When I apply filters on canvas Image it reduce the image width HOT 3
- [Bug]: `Group.prototype.getObjectsBoundingBox` is no longer available in version v6 rc1
- [Bug]: Textbox does not wrap word when their is no space in words. HOT 1
- [Feature]: Interaction Based on Visual Layering Order HOT 1
- [Feature]: Undo Redo for EraserBrush HOT 1
- [Bug]: hidden textarea make parent overflow hidden div scroll when editing
- CharSpacing not working with textbox object.
- [Bug]: Overwrite fabric.util.createClass for Textbox not working in latest version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabric.js.