Skip to content

Commit

Permalink
Release v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kumilingus authored Oct 15, 2019
1 parent 80fd72f commit 6c547fe
Show file tree
Hide file tree
Showing 37 changed files with 2,935 additions and 1,945 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
15-10-2019 (v3.1.0)

* add RoughJS demo
* add elementTools: Button, Remove, Boundary
* improve low-level performance for large graphs
* fix ES5 dependencies
* dia.Paper - validateMagnet() callback has `evt` argument
* dia.Paper - ignore viewport when removing views, register unmounted views on render
* dia.Graph - fix bfs() stop condition
* dia.Element - make sure only elements are taken into account in fitEmbeds()
* dia.LinkView - fix label rendering after multiple changes made to model
* dia.LinkView - fix missing `pointerup` event for non-interactive labels
* linkTools.Boundary - padding can be defined separately for each side
* dia.ToolView - support reusable tools
* connectors.jumpover - add `radius` option to make corners rounded
* layout.DirectedGraph - remove unnecessary vertices
* dia.attributes - add `stubs` option to `connection` attribute
* dia.attributes - add `displayEmpty` for text elements
* Vectorizer - fix e2c() overflowing the stack in normalizePathData()
* Geometry - add simplify() to Polyline (remove redundant points)

02-08-2019 (v3.0.4)

* package.json - add a browser key to point to dist (fix webpack build in IE11)
Expand Down
89 changes: 69 additions & 20 deletions dist/geometry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JointJS v3.0.4 (2019-08-02) - JavaScript diagramming library
/*! JointJS v3.1.0 (2019-10-15) - JavaScript diagramming library
This Source Code Form is subject to the terms of the Mozilla Public
Expand Down Expand Up @@ -3799,6 +3799,52 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
return this;
},

simplify: function(opt) {
if ( opt === void 0 ) opt = {};


var points = this.points;
if (points.length < 3) { return this; } // we need at least 3 points

// TODO: we may also accept startIndex and endIndex to specify where to start and end simplification
var threshold = opt.threshold || 0; // = max distance of middle point from chord to be simplified

// start at the beginning of the polyline and go forward
var currentIndex = 0;
// we need at least one intermediate point (3 points) in every iteration
// as soon as that stops being true, we know we reached the end of the polyline
while (points[currentIndex + 2]) {
var firstIndex = currentIndex;
var middleIndex = (currentIndex + 1);
var lastIndex = (currentIndex + 2);

var firstPoint = points[firstIndex];
var middlePoint = points[middleIndex];
var lastPoint = points[lastIndex];

var chord = new Line(firstPoint, lastPoint); // = connection between first and last point
var closestPoint = chord.closestPoint(middlePoint); // = closest point on chord from middle point
var closestPointDistance = closestPoint.distance(middlePoint);
if (closestPointDistance <= threshold) {
// middle point is close enough to the chord = simplify
// 1) remove middle point:
points.splice(middleIndex, 1);
// 2) in next iteration, investigate the newly-created triplet of points
// - do not change `currentIndex`
// = (first point stays, point after removed point becomes middle point)
} else {
// middle point is far from the chord
// 1) preserve middle point
// 2) in next iteration, move `currentIndex` by one step:
currentIndex += 1;
// = (point after first point becomes first point)
}
}

// `points` array was modified in-place
return this;
},

tangentAt: function(ratio) {

var points = this.points;
Expand Down Expand Up @@ -4374,18 +4420,21 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
// @return {rect} representing the union of both rectangles.
union: function(rect) {

rect = new Rect(rect);
var myOrigin = this.origin();
var myCorner = this.corner();
var rOrigin = rect.origin();
var rCorner = rect.corner();

var originX = min(myOrigin.x, rOrigin.x);
var originY = min(myOrigin.y, rOrigin.y);
var cornerX = max(myCorner.x, rCorner.x);
var cornerY = max(myCorner.y, rCorner.y);

return new Rect(originX, originY, cornerX - originX, cornerY - originY);
var u = new Rect(rect);
var ref = this;
var x = ref.x;
var y = ref.y;
var width = ref.width;
var height = ref.height;
var rx = u.x;
var ry = u.y;
var rw = u.width;
var rh = u.height;
var ux = u.x = min(x, rx);
var uy = u.y = min(y, ry);
u.width = max(x + width, rx + rw) - ux;
u.height = max(y + height, ry + rh) - uy;
return u;
}
};

Expand Down Expand Up @@ -5436,24 +5485,24 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
return this.regexSupportedData.test(data);
};

exports.bezier = bezier;
exports.Curve = Curve;
exports.Ellipse = Ellipse;
exports.Line = Line;
exports.Path = Path;
exports.Point = Point;
exports.Polyline = Polyline;
exports.Rect = Rect;
exports.scale = scale;
exports.normalizeAngle = normalizeAngle;
exports.snapToGrid = snapToGrid;
exports.toDeg = toDeg;
exports.toRad = toRad;
exports.random = random;
exports.bezier = bezier;
exports.ellipse = ellipse;
exports.line = line;
exports.normalizeAngle = normalizeAngle;
exports.point = point;
exports.random = random;
exports.rect = rect;
exports.scale = scale;
exports.snapToGrid = snapToGrid;
exports.toDeg = toDeg;
exports.toRad = toRad;

Object.defineProperty(exports, '__esModule', { value: true });

Expand Down
4 changes: 2 additions & 2 deletions dist/geometry.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/joint.core.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6c547fe

Please sign in to comment.