Skip to content

Commit

Permalink
refactor(d3-zoom): use new v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Aug 26, 2020
1 parent 98c41d2 commit 3fe6a95
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/hooks/useD3Zoom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useRef, MutableRefObject } from 'react';
import { event } from 'd3-selection';

import { useStoreState, useStoreActions } from '../store/hooks';
import { FlowTransform } from '../types';
Expand Down Expand Up @@ -53,7 +52,7 @@ export default ({
if (selectionKeyPressed) {
d3Zoom.on('zoom', null);
} else {
d3Zoom.on('zoom', () => {
d3Zoom.on('zoom', (event: any) => {
updateTransform(event.transform);

if (onMove) {
Expand All @@ -68,7 +67,7 @@ export default ({
useEffect(() => {
if (d3Zoom) {
if (onMoveStart) {
d3Zoom.on('start', () => {
d3Zoom.on('start', (event: any) => {
if (viewChanged(prevTransform.current, event.transform)) {
const flowTransform = eventToFlowTransform(event.transform);
prevTransform.current = flowTransform;
Expand All @@ -85,7 +84,7 @@ export default ({
useEffect(() => {
if (d3Zoom) {
if (onMoveEnd) {
d3Zoom.on('end', () => {
d3Zoom.on('end', (event: any) => {
if (viewChanged(prevTransform.current, event.transform)) {
const flowTransform = eventToFlowTransform(event.transform);
prevTransform.current = flowTransform;
Expand All @@ -101,7 +100,7 @@ export default ({

useEffect(() => {
if (d3Zoom) {
d3Zoom.filter(() => {
d3Zoom.filter((event: any) => {
if (!paneMoveable) {
return false;
}
Expand Down

0 comments on commit 3fe6a95

Please sign in to comment.