feat(fitView): add padding option
This commit is contained in:
Vendored
+14
-8
@@ -29936,7 +29936,8 @@
|
||||
case FIT_VIEW:
|
||||
{
|
||||
var bounds = getBoundingBox(state.nodes);
|
||||
var k = Math.min(state.width, state.height) / Math.max(bounds.width, bounds.height);
|
||||
var maxBoundsSize = Math.max(bounds.width, bounds.height);
|
||||
var k = Math.min(state.width, state.height) / (maxBoundsSize + maxBoundsSize * action.payload.padding);
|
||||
var boundsCenterX = bounds.x + bounds.width / 2;
|
||||
var boundsCenterY = bounds.y + bounds.height / 2;
|
||||
var transform = [state.width / 2 - boundsCenterX * k, state.height / 2 - boundsCenterY * k];
|
||||
@@ -30075,9 +30076,14 @@
|
||||
}
|
||||
};
|
||||
};
|
||||
var fitView = function fitView() {
|
||||
var fitView = function fitView(_ref2) {
|
||||
var _ref2$padding = _ref2.padding,
|
||||
padding = _ref2$padding === void 0 ? 0 : _ref2$padding;
|
||||
return {
|
||||
type: FIT_VIEW
|
||||
type: FIT_VIEW,
|
||||
payload: {
|
||||
padding: padding
|
||||
}
|
||||
};
|
||||
};
|
||||
var zoomIn = function zoomIn() {
|
||||
@@ -30098,9 +30104,9 @@
|
||||
}
|
||||
};
|
||||
};
|
||||
var setNodesSelection = function setNodesSelection(_ref2) {
|
||||
var isActive = _ref2.isActive,
|
||||
selection = _ref2.selection;
|
||||
var setNodesSelection = function setNodesSelection(_ref3) {
|
||||
var isActive = _ref3.isActive,
|
||||
selection = _ref3.selection;
|
||||
return {
|
||||
type: SET_NODES_SELECTION,
|
||||
payload: {
|
||||
@@ -32776,8 +32782,8 @@
|
||||
props.onLoad({
|
||||
nodes: state.nodes,
|
||||
edges: state.edges,
|
||||
fitView: function fitView$1() {
|
||||
return dispatch(fitView());
|
||||
fitView: function fitView$1(opts) {
|
||||
return dispatch(fitView(opts));
|
||||
},
|
||||
zoomIn: function zoomIn$1() {
|
||||
return dispatch(zoomIn());
|
||||
|
||||
Reference in New Issue
Block a user