fix: use global nodeExtent if node.extent is undefined
This commit is contained in:
@@ -54,15 +54,16 @@ const defaultState = (): State => ({
|
|||||||
d3ZoomHandler: null,
|
d3ZoomHandler: null,
|
||||||
minZoom: 0.5,
|
minZoom: 0.5,
|
||||||
maxZoom: 2,
|
maxZoom: 2,
|
||||||
|
|
||||||
translateExtent: [
|
translateExtent: [
|
||||||
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
|
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
|
||||||
[Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY],
|
[Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY],
|
||||||
],
|
],
|
||||||
|
|
||||||
nodeExtent: [
|
nodeExtent: [
|
||||||
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
|
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
|
||||||
[Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY],
|
[Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY],
|
||||||
],
|
],
|
||||||
|
|
||||||
preventScrolling: true,
|
preventScrolling: true,
|
||||||
zoomOnScroll: true,
|
zoomOnScroll: true,
|
||||||
zoomOnPinch: true,
|
zoomOnPinch: true,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { XYPosition, Position, SnapGrid, Element, XYZPosition, Dimensions } from
|
|||||||
import { DefaultNodeTypes } from './components'
|
import { DefaultNodeTypes } from './components'
|
||||||
import { HandleElement, ValidConnectionFunc } from './handle'
|
import { HandleElement, ValidConnectionFunc } from './handle'
|
||||||
|
|
||||||
|
/** Defined as [[x-from, y-from], [x-to, y-to]] **/
|
||||||
export type CoordinateExtent = [[number, number], [number, number]]
|
export type CoordinateExtent = [[number, number], [number, number]]
|
||||||
|
|
||||||
export type NodeHandleBounds = {
|
export type NodeHandleBounds = {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export const createPositionChange = (
|
|||||||
|
|
||||||
if (diff) {
|
if (diff) {
|
||||||
const nextPosition = { x: node.position.x + diff.x, y: node.position.y + diff.y }
|
const nextPosition = { x: node.position.x + diff.x, y: node.position.y + diff.y }
|
||||||
let currentExtent = node.extent === 'parent' ? nodeExtent : node.extent
|
let currentExtent = node.extent === 'parent' || typeof node.extent === 'undefined' ? nodeExtent : node.extent
|
||||||
|
|
||||||
if (node.extent === 'parent' && parent && node.dimensions.width && node.dimensions.height) {
|
if (node.extent === 'parent' && parent && node.dimensions.width && node.dimensions.height) {
|
||||||
currentExtent =
|
currentExtent =
|
||||||
|
|||||||
Reference in New Issue
Block a user