Comments (7)
It is the defaults
:)
- wrong order of
merge
arguments super.default
is a function inCBase
class CLink extends CBase {
defaults() {
return joint.util.merge(
{},
super.defaults(),
{
type: "CLink",
attrs: {
line: {
stroke: "#ccc",
strokeWidth: 2
}
}
},
);
}
}
from joint.
Ooohh! 🤔
Ok, I have another questions. Why CBase
is merging super.defaults
, but CLink
is merging super.defaults()
? What is the difference between using super.defaults
as a value and calling super.defaults()
as a function?
from joint.
The shapes.standard.Link class is defined via the define method which using the extend method of Backbone. If you create a Backbone.Model
this way (ES5 way), the defaults
is a property, not a method. Therefore CBase
needs to access it as a property.
The ES Class CBase
defines the defaults
as a method. Therefore CLink
has to call it as a function.
I recommend reading this article which should explain this in detail. Also reading this Backbone issue might be helpful.
from joint.
Oohh, now I get it. Good thing to know :)
Thank you!!
from joint.
I have an extra question 🙏
Would it be possible to extend from 2 classes using this method? Lets say that I have CBaseLinkA
which defines the stroke
color (using the defaults()
) and CBaseLinkB
which defines the strokeWidth
(also using the defaults()
) and the markup
attribute. Would it be possible to do something like
class MyLink extends merge(CBaseLinkA, CBaseLinkB) {
defaults() {
return joint.util.merge(
{
attrs: { line: { fill: "red" } }
},
super.defaults() // ????
)
}
}
from joint.
Perhaps you can check this discussion.
from joint.
Hmmm, I think I saw similar stuff in SO, but I'm not really sure how to handle the defaults()
, since that is threated in a very special way. I'll play around and report back if I find a way of achieving this!
from joint.
Related Issues (20)
- [Bug]: Each object assigned to portProp makes the diagram slower to render HOT 2
- [Bug]: Unsupported URL Type "workspace on @joint/[email protected] HOT 1
- Unable to get Selectors to animate my Customized Link HOT 2
- Rendering issue when paper is loaded in background. HOT 2
- [Bug]: Grid-layer display only one when two or more papers exist at the same time
- [Bug]: contextmenu in V4 is not default-preventable HOT 11
- [Bug]: JJ+ stopped rendering CSS when exporting to PNG (possibly other formats too) HOT 7
- [Bug]: texWrap does not take SVG attributes into account HOT 13
- Command manager is saving the entire attrs object on each attr() call (unexpected behaviour?) HOT 4
- linkTools.Vertices: prevent vertex creation on labels
- Visio export not adding images HOT 4
- [Bug]: elementTools displacement when applying scaling HOT 2
- [Bug]: Link anchor not working correctly for custom shape HOT 2
- [Bug]: Highlighter path miscalculation with ports (only in Safari) HOT 2
- [Bug]: Can't import the named export 'V' from non EcmaScript module (only default export is available) HOT 1
- [Bug]: Changing link target or source breaks CommandManager in Angular HOT 4
- Unable to display tooltip when toggle fullscreen HOT 12
- [Bug]: paper 'render:done' event no longer fires after unfreeze HOT 2
- [Bug]: graph.fromJson resets undo/redo in commandManager with jointJS Plus HOT 4
- [Bug]: StrokeDasharray applied to link's arrows on Safari only HOT 4
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 joint.