Generated
+446
-347
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -25,7 +25,7 @@
|
|||||||
"release": "release-it"
|
"release": "release-it"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@welldone-software/why-did-you-render": "^4.3.0",
|
"@welldone-software/why-did-you-render": "^4.3.1",
|
||||||
"classcat": "^4.1.0",
|
"classcat": "^4.1.0",
|
||||||
"d3-selection": "^1.4.2",
|
"d3-selection": "^1.4.2",
|
||||||
"d3-zoom": "^1.8.3",
|
"d3-zoom": "^1.8.3",
|
||||||
@@ -41,25 +41,25 @@
|
|||||||
"@svgr/rollup": "^5.4.0",
|
"@svgr/rollup": "^5.4.0",
|
||||||
"@types/classnames": "^2.2.10",
|
"@types/classnames": "^2.2.10",
|
||||||
"@types/d3": "^5.7.2",
|
"@types/d3": "^5.7.2",
|
||||||
"@types/react": "^16.9.45",
|
"@types/react": "^16.9.46",
|
||||||
"@types/react-dom": "^16.9.8",
|
"@types/react-dom": "^16.9.8",
|
||||||
"autoprefixer": "^9.8.6",
|
"autoprefixer": "^9.8.6",
|
||||||
"babel-loader": "^8.1.0",
|
"babel-loader": "^8.1.0",
|
||||||
"babel-preset-react-app": "^9.1.2",
|
"babel-preset-react-app": "^9.1.2",
|
||||||
"cypress": "^4.12.1",
|
"cypress": "^5.0.0",
|
||||||
"postcss-nested": "^4.2.3",
|
"postcss-nested": "^4.2.3",
|
||||||
"prettier": "2.0.5",
|
"prettier": "2.0.5",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"release-it": "^13.6.6",
|
"release-it": "^13.6.8",
|
||||||
"rollup": "^2.23.1",
|
"rollup": "^2.26.4",
|
||||||
"rollup-plugin-babel": "^4.4.0",
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
"rollup-plugin-bundle-size": "^1.0.3",
|
"rollup-plugin-bundle-size": "^1.0.3",
|
||||||
"rollup-plugin-commonjs": "^10.1.0",
|
"rollup-plugin-commonjs": "^10.1.0",
|
||||||
"rollup-plugin-livereload": "^1.3.0",
|
"rollup-plugin-livereload": "^1.3.0",
|
||||||
"rollup-plugin-node-resolve": "^5.2.0",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
"rollup-plugin-peer-deps-external": "^2.2.3",
|
"rollup-plugin-peer-deps-external": "^2.2.3",
|
||||||
"rollup-plugin-postcss": "^3.1.4",
|
"rollup-plugin-postcss": "^3.1.5",
|
||||||
"rollup-plugin-replace": "^2.2.0",
|
"rollup-plugin-replace": "^2.2.0",
|
||||||
"rollup-plugin-serve": "^1.0.3",
|
"rollup-plugin-serve": "^1.0.3",
|
||||||
"rollup-plugin-terser": "^7.0.0",
|
"rollup-plugin-terser": "^7.0.0",
|
||||||
|
|||||||
@@ -256,7 +256,9 @@ export default (NodeComponent: ComponentType<NodeComponentProps>) => {
|
|||||||
|
|
||||||
const resizeObserver = new ResizeObserver((entries) => {
|
const resizeObserver = new ResizeObserver((entries) => {
|
||||||
for (let _ of entries) {
|
for (let _ of entries) {
|
||||||
updateNodeDimensions({ id, nodeElement: nodeElement.current! });
|
if (nodeElement.current) {
|
||||||
|
updateNodeDimensions({ id, nodeElement: nodeElement.current });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ const GraphView = ({
|
|||||||
const setMinMaxZoom = useStoreActions((actions) => actions.setMinMaxZoom);
|
const setMinMaxZoom = useStoreActions((actions) => actions.setMinMaxZoom);
|
||||||
const fitView = useStoreActions((actions) => actions.fitView);
|
const fitView = useStoreActions((actions) => actions.fitView);
|
||||||
const zoom = useStoreActions((actions) => actions.zoom);
|
const zoom = useStoreActions((actions) => actions.zoom);
|
||||||
|
const zoomTo = useStoreActions((actions) => actions.zoomTo);
|
||||||
|
|
||||||
const onZoomPaneClick = useCallback(
|
const onZoomPaneClick = useCallback(
|
||||||
(event: React.MouseEvent) => {
|
(event: React.MouseEvent) => {
|
||||||
@@ -167,6 +168,7 @@ const GraphView = ({
|
|||||||
fitView: (params = { padding: 0.1 }) => fitView(params),
|
fitView: (params = { padding: 0.1 }) => fitView(params),
|
||||||
zoomIn: () => zoom(0.2),
|
zoomIn: () => zoom(0.2),
|
||||||
zoomOut: () => zoom(-0.2),
|
zoomOut: () => zoom(-0.2),
|
||||||
|
zoomTo: (zoomLevel) => zoomTo(zoomLevel),
|
||||||
project,
|
project,
|
||||||
getElements,
|
getElements,
|
||||||
setTransform: (transform: FlowTransform) =>
|
setTransform: (transform: FlowTransform) =>
|
||||||
|
|||||||
+11
-3
@@ -129,7 +129,8 @@ export interface StoreModel {
|
|||||||
unsetUserSelection: Action<StoreModel>;
|
unsetUserSelection: Action<StoreModel>;
|
||||||
|
|
||||||
fitView: Action<StoreModel, FitViewParams>;
|
fitView: Action<StoreModel, FitViewParams>;
|
||||||
zoom: Action<StoreModel, number>;
|
zoomTo: Action<StoreModel, number>;
|
||||||
|
zoom: Thunk<StoreModel, number, any, StoreModel>;
|
||||||
zoomIn: Thunk<StoreModel>;
|
zoomIn: Thunk<StoreModel>;
|
||||||
zoomOut: Thunk<StoreModel>;
|
zoomOut: Thunk<StoreModel>;
|
||||||
}
|
}
|
||||||
@@ -418,9 +419,9 @@ export const storeModel: StoreModel = {
|
|||||||
state.transform = [fittedTransform.x, fittedTransform.y, fittedTransform.k];
|
state.transform = [fittedTransform.x, fittedTransform.y, fittedTransform.k];
|
||||||
}),
|
}),
|
||||||
|
|
||||||
zoom: action((state, amount) => {
|
zoomTo: action((state, zoomLevel) => {
|
||||||
const { d3Selection, transform, minZoom, maxZoom } = state;
|
const { d3Selection, transform, minZoom, maxZoom } = state;
|
||||||
const nextZoom = clamp(transform[2] + amount, minZoom, maxZoom);
|
const nextZoom = clamp(zoomLevel, minZoom, maxZoom);
|
||||||
|
|
||||||
if (d3Selection) {
|
if (d3Selection) {
|
||||||
// we want to zoom in and out to the center of the zoom pane
|
// we want to zoom in and out to the center of the zoom pane
|
||||||
@@ -439,6 +440,13 @@ export const storeModel: StoreModel = {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
zoom: thunk((actions, amount, helpers) => {
|
||||||
|
const { transform } = helpers.getState();
|
||||||
|
const nextZoom = transform[2] + amount;
|
||||||
|
|
||||||
|
actions.zoomTo(nextZoom);
|
||||||
|
}),
|
||||||
|
|
||||||
zoomIn: thunk((actions) => {
|
zoomIn: thunk((actions) => {
|
||||||
actions.zoom(0.2);
|
actions.zoom(0.2);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export type ProjectFunc = (position: XYPosition) => XYPosition;
|
|||||||
export type OnLoadParams = {
|
export type OnLoadParams = {
|
||||||
zoomIn: () => void;
|
zoomIn: () => void;
|
||||||
zoomOut: () => void;
|
zoomOut: () => void;
|
||||||
|
zoomTo: (zoomLevel: number) => void;
|
||||||
fitView: FitViewFunc;
|
fitView: FitViewFunc;
|
||||||
project: ProjectFunc;
|
project: ProjectFunc;
|
||||||
getElements: () => Elements;
|
getElements: () => Elements;
|
||||||
|
|||||||
Reference in New Issue
Block a user