diff --git a/packages/vx-demo/components/gallery.js b/packages/vx-demo/components/gallery.js
index 71e71aa3d..c5936085d 100644
--- a/packages/vx-demo/components/gallery.js
+++ b/packages/vx-demo/components/gallery.js
@@ -42,6 +42,7 @@ import LinkTypes from './tiles/linkTypes';
import Threshold from './tiles/threshold';
import Chord from './tiles/chord';
import Polygons from './tiles/polygons';
+import ZoomI from './tiles/zoom-i';
const items = [
'#242424',
@@ -903,7 +904,23 @@ export default class Gallery extends React.Component {
-
-
@vx/zoom
+
@vx/Zoom
+
+
+
+
Installation
npm install --save @vx/zoom
+
Components
+
+
API
+
<Zoom />
+
+
+
+
# Zoom.children<func> required
+
# Zoom.constrain<func>
+
By default constrain() will only constrain scale values. To change
+constraints you can pass in your own constrain function as a prop.
+
For example, if you wanted to constrain your view to within [[0, 0], [width, height]]:
+
function constrain(transformMatrix, prevTransformMatrix) {
+ const min = applyMatrixToPoint(transformMatrix, { x: 0, y: 0 });
+ const max = applyMatrixToPoint(transformMatrix, { x: width, y: height });
+ if (max.x < width || max.y < height) {
+ return prevTransformMatrix;
+ }
+ if (min.x > 0 || min.y > 0) {
+ return prevTransformMatrix;
+ }
+ return transformMatrix;
+}
+
@param {matrix} transformMatrix
+@param {matrix} prevTransformMatrix
+@returns {martix}
+
# Zoom.height<number> required
+
# Zoom.scaleXMax<number>
+
# Zoom.scaleXMin<number>
+
# Zoom.scaleYMax<number>
+
# Zoom.scaleYMin<number>
+
# Zoom.transformMatrix<shape[object Object]>
Default | {
+ scaleX: 1,
+ scaleY: 1,
+ translateX: 0,
+ translateY: 0,
+ skewX: 0,
+ skewY: 0
+} |
+
# Zoom.wheelDelta<func>
+
wheelDelta(event.deltaY)
+
+
A function that returns {scaleX,scaleY} factors to scale the matrix by.
+Scale factors greater than 1 will increase (zoom in), less than 1 will descrease (zoom out).
Default | event => {
+ return -event.deltaY > 0 ? { scaleX: 1.1, scaleY: 1.1 } : { scaleX: 0.9, scaleY: 0.9 };
+} |
+
# Zoom.width<number> required
+
diff --git a/packages/vx-mock-data/src/generators/genPhyllotaxis.js b/packages/vx-mock-data/src/generators/genPhyllotaxis.js
new file mode 100644
index 000000000..a6537a491
--- /dev/null
+++ b/packages/vx-mock-data/src/generators/genPhyllotaxis.js
@@ -0,0 +1,11 @@
+export default function genPhyllotaxis({ radius, width, height }) {
+ const theta = Math.PI * (3 - Math.sqrt(5));
+ return i => {
+ const r = radius * Math.sqrt(i);
+ const a = theta * i;
+ return {
+ x: width / 2 + r * Math.cos(a),
+ y: height / 2 + r * Math.sin(a)
+ };
+ };
+}
diff --git a/packages/vx-mock-data/src/index.js b/packages/vx-mock-data/src/index.js
index aeff68674..f7e951011 100644
--- a/packages/vx-mock-data/src/index.js
+++ b/packages/vx-mock-data/src/index.js
@@ -2,6 +2,7 @@ export { default as genDateValue } from './generators/genDateValue';
export { default as genRandomNormalPoints } from './generators/genRandomNormalPoints';
export { default as genBin } from './generators/genBin';
export { default as genBins } from './generators/genBins';
+export { default as genPhyllotaxis } from './generators/genPhyllotaxis';
export { default as genStats } from './generators/genStats';
export { default as appleStock } from './mocks/appleStock';
export { default as letterFrequency } from './mocks/letterFrequency';
diff --git a/packages/vx-mock-data/test/genPhyllotaxis.test.js b/packages/vx-mock-data/test/genPhyllotaxis.test.js
new file mode 100644
index 000000000..0bfb32081
--- /dev/null
+++ b/packages/vx-mock-data/test/genPhyllotaxis.test.js
@@ -0,0 +1,28 @@
+import { genPhyllotaxis } from '../src';
+
+describe('generators/genPhyllotaxis', () => {
+ test('it should be defined', () => {
+ expect(genPhyllotaxis).toBeDefined();
+ });
+
+ test('it should return a function', () => {
+ const pointFn = genPhyllotaxis({
+ radius: 10,
+ width: 200,
+ height: 200
+ });
+ expect(typeof pointFn).toEqual('function');
+ });
+
+ test('it should return a point [x, y] when calling the returned function', () => {
+ const pointFn = genPhyllotaxis({
+ radius: 10,
+ width: 200,
+ height: 200
+ });
+ const point = pointFn(3);
+ const expected = { x: 110, y: 113 };
+ expect(Math.floor(point.x)).toEqual(expected.x);
+ expect(Math.floor(point.y)).toEqual(expected.y);
+ });
+});
diff --git a/packages/vx-zoom/Readme.md b/packages/vx-zoom/Readme.md
index 4911266be..9e9ba7ade 100644
--- a/packages/vx-zoom/Readme.md
+++ b/packages/vx-zoom/Readme.md
@@ -1,5 +1,86 @@
-# @vx/zoom
+# @vx/Zoom
+
+