From 01c52975bb4d35397d006efb1105908b2433d731 Mon Sep 17 00:00:00 2001 From: James Conkling Date: Mon, 18 Jan 2021 13:55:48 -0500 Subject: [PATCH] move controls to bindings --- examples/hierarchy/index.ts | 2 +- examples/pixi-perf/index.ts | 4 ++-- examples/pixi-render-perf/index.ts | 2 +- examples/pixi/index.ts | 6 +++--- .../webgl/bindings/native}/download.ts | 0 .../webgl/bindings/native}/selection.ts | 2 +- src/{controls => renderers/webgl/bindings/native}/zoom.ts | 0 src/renderers/webgl/bindings/react/zoom.ts | 6 +++--- 8 files changed, 11 insertions(+), 11 deletions(-) rename src/{controls => renderers/webgl/bindings/native}/download.ts (100%) rename src/{controls => renderers/webgl/bindings/native}/selection.ts (99%) rename src/{controls => renderers/webgl/bindings/native}/zoom.ts (100%) diff --git a/examples/hierarchy/index.ts b/examples/hierarchy/index.ts index 31300bab..cb926649 100644 --- a/examples/hierarchy/index.ts +++ b/examples/hierarchy/index.ts @@ -2,7 +2,7 @@ import Stats from 'stats.js' import * as Hierarchy from '../../src/layout/hierarchy' import * as Force from '../../src/layout/force' import * as Graph from '../../src/' -import * as Zoom from '../../src/controls/zoom' +import * as Zoom from '../../src/renderers/webgl/bindings/native/zoom' import * as WebGL from '../../src/renderers/webgl' import graphData from '../../data/tmp-data' diff --git a/examples/pixi-perf/index.ts b/examples/pixi-perf/index.ts index b976376f..65428688 100644 --- a/examples/pixi-perf/index.ts +++ b/examples/pixi-perf/index.ts @@ -1,8 +1,8 @@ import Stats from 'stats.js' import * as Force from '../../src/layout/force' import * as Graph from '../../src/' -import * as Zoom from '../../src/controls/zoom' -import * as Download from '../../src/controls/download' +import * as Zoom from '../../src/renderers/webgl/bindings/native/zoom' +import * as Download from '../../src/renderers/webgl/bindings/native/download' import * as WebGL from '../../src/renderers/webgl' import * as Png from '../../src/renderers/image' import graphData from '../../data/tmp-data' diff --git a/examples/pixi-render-perf/index.ts b/examples/pixi-render-perf/index.ts index 3cc2287d..a873a697 100644 --- a/examples/pixi-render-perf/index.ts +++ b/examples/pixi-render-perf/index.ts @@ -1,6 +1,6 @@ import Stats from 'stats.js' import * as Force from '../../src/layout/force' -import * as Zoom from '../../src/controls/zoom' +import * as Zoom from '../../src/renderers/webgl/bindings/native/zoom' import * as Graph from '../../src' import * as WebGL from '../../src/renderers/webgl' import graphData from '../../data/tmp-data' diff --git a/examples/pixi/index.ts b/examples/pixi/index.ts index 9b462c66..6fdaedf3 100644 --- a/examples/pixi/index.ts +++ b/examples/pixi/index.ts @@ -1,9 +1,9 @@ import Stats from 'stats.js' import * as Force from '../../src/layout/force' import * as Subgraph from '../../src/layout/subgraph' -import * as Zoom from '../../src/controls/zoom' -import * as Selection from '../../src/controls/selection' -import * as Download from '../../src/controls/download' +import * as Zoom from '../../src/renderers/webgl/bindings/native/zoom' +import * as Selection from '../../src/renderers/webgl/bindings/native/selection' +import * as Download from '../../src/renderers/webgl/bindings/native/download' import * as Cluster from '../../src/layout/cluster' import * as WebGL from '../../src/renderers/webgl' import * as Png from '../../src/renderers/image' diff --git a/src/controls/download.ts b/src/renderers/webgl/bindings/native/download.ts similarity index 100% rename from src/controls/download.ts rename to src/renderers/webgl/bindings/native/download.ts diff --git a/src/controls/selection.ts b/src/renderers/webgl/bindings/native/selection.ts similarity index 99% rename from src/controls/selection.ts rename to src/renderers/webgl/bindings/native/selection.ts index 45bc45fc..698b5838 100644 --- a/src/controls/selection.ts +++ b/src/renderers/webgl/bindings/native/selection.ts @@ -1,4 +1,4 @@ -import { ViewportDragDecelerateEvent, ViewportDragEvent, ViewportPointerEvent } from '../renderers/webgl' +import { ViewportDragDecelerateEvent, ViewportDragEvent, ViewportPointerEvent } from '../..' const DEFAULT_TOP = '100px' diff --git a/src/controls/zoom.ts b/src/renderers/webgl/bindings/native/zoom.ts similarity index 100% rename from src/controls/zoom.ts rename to src/renderers/webgl/bindings/native/zoom.ts diff --git a/src/renderers/webgl/bindings/react/zoom.ts b/src/renderers/webgl/bindings/react/zoom.ts index 7a5ac927..f38096e3 100644 --- a/src/renderers/webgl/bindings/react/zoom.ts +++ b/src/renderers/webgl/bindings/react/zoom.ts @@ -2,15 +2,15 @@ import { createElement, FunctionComponent } from 'react' import { ButtonGroup } from './buttonGroup' -export { clampZoom } from '../../../../controls/zoom' - - export type Props = { onZoomIn?: () => void onZoomOut?: () => void } +export const clampZoom = (min: number, max: number, zoom: number) => Math.max(min, Math.min(max, zoom)) + + // TODO - memoize, disable on min/max zoom export const Zoom: FunctionComponent = (props) => {