Skip to content

Commit 673da7a

Browse files
authored
docs: align docs tables with current API (#557)
1 parent 65434dc commit 673da7a

2 files changed

Lines changed: 106 additions & 44 deletions

File tree

src/stories/docs/handlers.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,58 +18,62 @@ export type ComponentProps = Record<
1818

1919
export const handlersTable: ComponentProps = {
2020
zoomIn: {
21-
type: ["function(step, animationTime, animationName)"],
21+
type: ["function(step, animationTime, animationType)"],
2222
parameters: [
2323
"step: number = 0.5",
2424
"animationTime: number = 300",
25-
"animationName: string = easeOut",
25+
"animationType: keyof typeof animations = easeOut",
2626
],
2727
description: "Function used for zoom in button",
2828
},
2929
zoomOut: {
30-
type: ["function(step, animationTime, animationName)"],
30+
type: ["function(step, animationTime, animationType)"],
3131
parameters: [
3232
"step: number = 0.5",
3333
"animationTime: number = 300",
34-
"animationName: string = easeOut",
34+
"animationType: keyof typeof animations = easeOut",
3535
],
3636
description: "Function used for zoom out button",
3737
},
3838
setTransform: {
39-
type: ["function(x, y, scale, animationTime, animationName)"],
39+
type: ["function(x, y, scale, animationTime, animationType)"],
4040
parameters: [
4141
"x: number",
4242
"y: number",
4343
"scale: number",
4444
"animationTime: number = 300",
45-
"animationName: string = easeOut",
45+
"animationType: keyof typeof animations = easeOut",
4646
],
4747
description: "Function used for custom transformation animation",
4848
},
4949
resetTransform: {
50-
type: ["function(animationTime, animationName)"],
50+
type: ["function(animationTime, animationType)"],
5151
parameters: [
52-
"animationTime: number = 300",
53-
"animationName: string = easeOut",
52+
"animationTime: number = 200",
53+
"animationType: keyof typeof animations = easeOut",
5454
],
5555
description: "Function used for reset button",
5656
},
5757
centerView: {
58-
type: ["function(scale, animationTime, animationName)"],
58+
type: ["function(scale, animationTime, animationType)"],
5959
parameters: [
6060
"scale: number = undefined",
61-
"animationTime: number = 300",
62-
"animationName: string = easeOut",
61+
"animationTime: number = 200",
62+
"animationType: keyof typeof animations = easeOut",
6363
],
6464
description: "Function used for centering the content component",
6565
},
6666
zoomToElement: {
67-
type: ["function(node, customZoom, animationTime, animationName)"],
67+
type: [
68+
"function(node, scale, animationTime, animationType, offsetX, offsetY)",
69+
],
6870
parameters: [
6971
"node: HTMLElement | string",
70-
"customScale: number = undefined",
71-
"animationTime: number = 300",
72-
"animationName: string = easeOut",
72+
"scale: number = undefined",
73+
"animationTime: number = 600",
74+
"animationType: keyof typeof animations = easeOut",
75+
"offsetX: number = 0",
76+
"offsetY: number = 0",
7377
],
7478
description:
7579
"This function make a transition for certain node provided to the function(as node element or it's id string). It allows only to zoom elements with offsetWidth and offsetHeight properties - since SVG's doesn't have those, it is impossible to perform it on such elements.",

src/stories/docs/props.tsx

Lines changed: 86 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export const componentPropsTable: Record<
4949
string,
5050
Omit<ControlsOptionsType, "name">
5151
> = {
52+
children: {
53+
type: ["React.ReactNode"],
54+
defaultValue: "required",
55+
description: "Content rendered inside the transformable area.",
56+
},
5257
wrapperClass: {
5358
type: ["string"],
5459
defaultValue: "''",
@@ -60,18 +65,47 @@ export const componentPropsTable: Record<
6065
description: "Content element class",
6166
},
6267
wrapperStyle: {
63-
type: ["ReactCSSProperties"],
68+
type: ["React.CSSProperties"],
6469
defaultValue: "undefined",
6570
description: "Wrapper element style object",
6671
},
6772
contentStyle: {
68-
type: ["ReactCSSProperties"],
73+
type: ["React.CSSProperties"],
6974
defaultValue: "undefined",
7075
description: "Content element style object",
7176
},
77+
wrapperProps: {
78+
type: ["React.HTMLAttributes<HTMLDivElement>"],
79+
defaultValue: "{}",
80+
description: "Additional props spread onto the wrapper element.",
81+
},
82+
contentProps: {
83+
type: ["React.HTMLAttributes<HTMLDivElement>"],
84+
defaultValue: "{}",
85+
description: "Additional props spread onto the content element.",
86+
},
87+
infinite: {
88+
type: ["boolean"],
89+
defaultValue: "false",
90+
description:
91+
"Render the infinite dot-grid background behind the content so it pans and scales with the transform.",
92+
},
7293
};
7394

74-
export const wrapperPropsTable: ComponentProps = {
95+
export const wrapperPropsTable: Record<
96+
string,
97+
| Omit<ControlsOptionsType, "name" | "isObjectRow">
98+
| Record<string, Omit<ControlsOptionsType, "name" | "isObjectRow">>
99+
> = {
100+
children: {
101+
type: [
102+
"React.ReactNode",
103+
"((ref: ReactZoomPanPinchContentRef) => React.ReactNode)",
104+
],
105+
defaultValue: "undefined",
106+
description:
107+
"Wrapper content. Can be regular React nodes or a render function receiving controls and instance access.",
108+
},
75109
ref: {
76110
type: ["React.Ref<ReactZoomPanPinchRef>"],
77111
defaultValue: "undefined",
@@ -102,26 +136,26 @@ export const wrapperPropsTable: ComponentProps = {
102136
"This is 'global' disable props. Setting it as a 'true' value blocks all functionalities of library. For disabling parts of it like panning, zooming, pinch - checkout the dedicated sections below.",
103137
},
104138
minPositionX: {
105-
type: ["number"],
139+
type: ["number", "null"],
106140
defaultValue: String(initialSetup.minPositionX),
107141
description:
108142
"Bounding position which will limit the transformation to given value. Value should be provided in px.",
109143
},
110144
maxPositionX: {
111-
type: ["number"],
145+
type: ["number", "null"],
112146
defaultValue: String(initialSetup.maxPositionX),
113147
description:
114148
"Bounding position which will limit the transformation to given value. Value should be provided in px.",
115149
},
116150
minPositionY: {
117-
type: ["number"],
151+
type: ["number", "null"],
118152
defaultValue: String(initialSetup.minPositionY),
119153
description:
120154
"Bounding position which will limit the transformation to given value. Value should be provided in px.",
121155
},
122156
maxPositionY: {
123-
type: ["number"],
124-
defaultValue: String(initialSetup.minPositionY),
157+
type: ["number", "null"],
158+
defaultValue: String(initialSetup.maxPositionY),
125159
description:
126160
"Bounding position which will limit the transformation to given value. Value should be provided in px.",
127161
},
@@ -160,7 +194,7 @@ export const wrapperPropsTable: ComponentProps = {
160194
"Used to disable panning, zooming boundary padding effect. By enabling this option, you will not be able to zoom outside the image area.",
161195
},
162196
customTransform: {
163-
type: ["function"],
197+
type: ["(x: number, y: number, scale: number) => string"],
164198
defaultValue: "undefined",
165199
description:
166200
"We can provide custom transform function to provide different way of handling our transform logic. If we need performance we can import getMatrixTransformStyles functions and replace default one. WARNING: default transform prevents svg blur on the safari.",
@@ -173,7 +207,7 @@ export const wrapperPropsTable: ComponentProps = {
173207
},
174208
detached: {
175209
type: ["boolean"],
176-
defaultValue: String(initialSetup.smooth),
210+
defaultValue: String(initialSetup.detached),
177211
description:
178212
"Allows to prevent CSS being applied to content element. It allows to add the functionality to canvas with some custom transforming logic.",
179213
},
@@ -207,7 +241,7 @@ export const wrapperPropsTable: ComponentProps = {
207241
"Disable only touchpad zooming functionality, it will NOT affect pinching and mouse wheel.",
208242
},
209243
activationKeys: {
210-
type: ["string[]"],
244+
type: ["string[]", "((keys: string[]) => boolean)"],
211245
defaultValue: String(initialSetup.wheel.activationKeys),
212246
description:
213247
"List of keys which, when held down, should activate this feature.",
@@ -230,6 +264,12 @@ export const wrapperPropsTable: ComponentProps = {
230264
defaultValue: String(initialSetup.panning.disabled),
231265
description: "Disable the panning feature.",
232266
},
267+
velocityDisabled: {
268+
type: ["boolean"],
269+
defaultValue: String(initialSetup.panning.velocityDisabled),
270+
description:
271+
"Disable inertia and velocity-based continuation after panning ends.",
272+
},
233273
lockAxisX: {
234274
type: ["boolean"],
235275
defaultValue: String(initialSetup.panning.lockAxisX),
@@ -258,7 +298,7 @@ export const wrapperPropsTable: ComponentProps = {
258298
description: "Allow right click to initiate panning",
259299
},
260300
activationKeys: {
261-
type: ["string[]"],
301+
type: ["string[]", "((keys: string[]) => boolean)"],
262302
defaultValue: String(initialSetup.panning.activationKeys),
263303
description:
264304
"List of keys which, when held down, should activate this feature.",
@@ -287,6 +327,12 @@ export const wrapperPropsTable: ComponentProps = {
287327
description:
288328
"Disable the pinching zoom functionality, it will NOT affect mouse wheel/touchpad zooming.",
289329
},
330+
allowPanning: {
331+
type: ["boolean"],
332+
defaultValue: String(initialSetup.pinch.allowPanning),
333+
description:
334+
"Allow moving the content while pinching. When false, pinch only changes scale.",
335+
},
290336
excluded: {
291337
type: ["string[]"],
292338
defaultValue: String(initialSetup.pinch.excluded),
@@ -302,30 +348,36 @@ export const wrapperPropsTable: ComponentProps = {
302348
},
303349
disabled: {
304350
type: ["boolean"],
305-
defaultValue: String(initialSetup.panning.disabled),
306-
description: "Disable the panning feature.",
351+
defaultValue: String(initialSetup.trackPadPanning.disabled),
352+
description: "Disable the trackpad panning feature.",
353+
},
354+
velocityDisabled: {
355+
type: ["boolean"],
356+
defaultValue: String(initialSetup.trackPadPanning.velocityDisabled),
357+
description:
358+
"Disable inertia and velocity-based continuation after trackpad panning ends.",
307359
},
308360
lockAxisX: {
309361
type: ["boolean"],
310-
defaultValue: String(initialSetup.panning.lockAxisX),
362+
defaultValue: String(initialSetup.trackPadPanning.lockAxisX),
311363
description:
312-
"Disable the panning feature for the X axis (prevents horizontal panning).",
364+
"Disable the trackpad panning feature for the X axis (prevents horizontal panning).",
313365
},
314366
lockAxisY: {
315367
type: ["boolean"],
316-
defaultValue: String(initialSetup.panning.lockAxisY),
368+
defaultValue: String(initialSetup.trackPadPanning.lockAxisY),
317369
description:
318-
"Disable the panning feature for the Y axis (prevents vertical panning).",
370+
"Disable the trackpad panning feature for the Y axis (prevents vertical panning).",
319371
},
320372
activationKeys: {
321-
type: ["string[]"],
322-
defaultValue: String(initialSetup.panning.activationKeys),
373+
type: ["string[]", "((keys: string[]) => boolean)"],
374+
defaultValue: String(initialSetup.trackPadPanning.activationKeys),
323375
description:
324376
"List of keys which, when held down, should activate this feature.",
325377
},
326378
excluded: {
327379
type: ["string[]"],
328-
defaultValue: String(initialSetup.panning.excluded),
380+
defaultValue: String(initialSetup.trackPadPanning.excluded),
329381
description:
330382
"List of the class names or tags that should not activate this feature. (E.g. ['my-custom-class-name', 'div', 'a'])",
331383
},
@@ -379,7 +431,7 @@ export const wrapperPropsTable: ComponentProps = {
379431
disabled: {
380432
type: ["boolean"],
381433
defaultValue: String(initialSetup.zoomAnimation.disabled),
382-
description: "Disable the double click feature.",
434+
description: "Disable animated zoom alignment after zoom interactions.",
383435
},
384436
size: {
385437
type: ["number"],
@@ -407,7 +459,7 @@ export const wrapperPropsTable: ComponentProps = {
407459
disabled: {
408460
type: ["boolean"],
409461
defaultValue: String(initialSetup.autoAlignment.disabled),
410-
description: "Disable the double click feature.",
462+
description: "Disable automatic alignment back toward the allowed bounds.",
411463
},
412464
sizeX: {
413465
type: ["number"],
@@ -423,7 +475,7 @@ export const wrapperPropsTable: ComponentProps = {
423475
},
424476
velocityAlignmentTime: {
425477
type: ["number"],
426-
defaultValue: String(initialSetup.autoAlignment.animationTime),
478+
defaultValue: String(initialSetup.autoAlignment.velocityAlignmentTime),
427479
description:
428480
"Time of the velocity alignment animation. It is fired when acceleration begins when we are outside the wrapper limits (in the area defined by the above prop size)",
429481
},
@@ -447,13 +499,19 @@ export const wrapperPropsTable: ComponentProps = {
447499
disabled: {
448500
type: ["boolean"],
449501
defaultValue: String(initialSetup.velocityAnimation.disabled),
450-
description: "Disable the double click feature.",
502+
description: "Disable velocity-based panning continuation and inertia.",
451503
},
452-
sensitivity: {
504+
sensitivityTouch: {
453505
type: ["number"],
454-
defaultValue: String(initialSetup.velocityAnimation.animationTime),
506+
defaultValue: String(initialSetup.velocityAnimation.sensitivityTouch),
507+
description:
508+
"Controls how strongly touch interactions contribute to velocity.",
509+
},
510+
sensitivityMouse: {
511+
type: ["number"],
512+
defaultValue: String(initialSetup.velocityAnimation.sensitivityMouse),
455513
description:
456-
"Additional variable that allows you to control the sensitivity of panning velocity",
514+
"Controls how strongly mouse and trackpad interactions contribute to velocity.",
457515
},
458516
maxStrengthMouse: {
459517
type: ["number"],

0 commit comments

Comments
 (0)