-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Network: Consolidate code for generating endpoints #3422
Conversation
Looks good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question popped out from this PR:
Since when do we use static
in classes? Are we planning to incorporate it?
This won;t work for older browsers
* @param {ArrowData} arrowData | ||
* @static | ||
*/ | ||
static transform(points, arrowData) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static won't work on browsers that don't support ES6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we do use babel to convert es2015
syntax to 'regular' javascript. It's this line in the package.json
:
"babel-preset-es2015": "^6.24.1",
All es2015
(aka ES6
) syntax is transpiled to 'regular' javascript upon compilation with gulp
. To give an example:
class Node {
...
static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}) {
...
}
};
... becomes in the target vis.js
:
(0, _createClass3['default'])(Node, [{
...
}], [{
key: 'parseOptions',
value: function parseOptions(parentOptions, newOptions) {
var allowDeletion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var globalOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
...
}]);
return Node;
}();
static
just plain disappears in the target file vis.js
We've been done the transpilation for some time now. I really think we're OK here.
...if I'm missing something, please enlighten me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, you're right again =)
* Moved endpoint-specific code to module EndPoints * Further decomposed functionality for endpoints * Added commenting, notably for typedef's * Add next attempt at fixing travis bug
This is a preliminary refactoring of the endpoint definitions, in preparation for fixing #3412, #1993 and #3118.
All code related to the drawing of arrow types for edges has been moved to new module
EndPoints
and refactored.The intention is to make it as simple as possible to create new endpoints. My personal hope is that it becomes so simple, that users take it upon themselves to add new endpoints.
There is room for further simplification; any thoughts on this are welcome.