Skip to content

Commit

Permalink
Modified fitView to log values that it gets from store
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł Jaśpiński committed Aug 18, 2021
1 parent 110bdf7 commit ad72546
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
9 changes: 7 additions & 2 deletions dist/ReactFlow.esm.js

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

2 changes: 1 addition & 1 deletion dist/ReactFlow.esm.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions dist/ReactFlow.js

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

2 changes: 1 addition & 1 deletion dist/ReactFlow.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/hooks/useZoomPanHelper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useMemo } from 'react';
import { zoomIdentity } from 'd3-zoom';
import { useMemo } from 'react';
import { useStore, useStoreState } from '../store/hooks';
import { FitViewParams, FlowTransform, Rect, XYPosition, ZoomPanHelperFunctions } from '../types';
import { getRectOfNodes, getTransformForBounds, pointToRendererPoint } from '../utils/graph';

import { useStoreState, useStore } from '../store/hooks';
import { getRectOfNodes, pointToRendererPoint, getTransformForBounds } from '../utils/graph';
import { FitViewParams, FlowTransform, ZoomPanHelperFunctions, Rect, XYPosition } from '../types';

const DEFAULT_PADDING = 0.1;

Expand Down Expand Up @@ -37,6 +37,7 @@ const useZoomPanHelper = (): ZoomPanHelperFunctions => {
},
fitView: (options: FitViewParams = { padding: DEFAULT_PADDING, includeHiddenNodes: false }) => {
const { nodes, width, height, minZoom, maxZoom } = store.getState();
console.log('fitView gets from store:',{height, width})

if (!nodes.length) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const isInputDOMNode = (e: ReactMouseEvent | DraggableEvent | KeyboardEve
export const getDimensions = (node: HTMLDivElement): Dimensions => {
const rect = node.getBoundingClientRect();
console.log('getDimensions returns:',{width: rect.width, height: rect.height})
return {width: rect.width, height: rect.height}
return { height: rect.height, width: rect.width}
}
// ({
// width: node.offsetWidth,
Expand Down

0 comments on commit ad72546

Please sign in to comment.