react-zoom-pan-pinch 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/index.cjs.js +54 -33
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.esm.js +54 -33
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +4 -1
  7. package/.eslintignore +0 -6
  8. package/.github/CODEOWNERS +0 -36
  9. package/.github/FUNDING.yml +0 -13
  10. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  11. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  12. package/.github/workflows/docs.yml +0 -34
  13. package/.github/workflows/release.yml +0 -46
  14. package/.github/workflows/tests.yml +0 -42
  15. package/.prettierrc +0 -10
  16. package/.releaserc.json +0 -63
  17. package/.storybook/main.js +0 -23
  18. package/.storybook/preview-head.html +0 -5
  19. package/.storybook/preview.js +0 -11
  20. package/.storybook/theme-overrides.css +0 -49
  21. package/CHANGELOG.md +0 -26
  22. package/Code_of_Conduct.md +0 -61
  23. package/Contributing.md +0 -236
  24. package/__tests__/features/props.spec.tsx +0 -11
  25. package/__tests__/features/rendering.spec.tsx +0 -36
  26. package/__tests__/shared/render.shared.tsx +0 -41
  27. package/__tests__/utils/controls.utils.tsx +0 -25
  28. package/__tests__/utils/example.tsx +0 -81
  29. package/commitlint.config.js +0 -1
  30. package/dist/__tests__/features/props.spec.d.ts +0 -1
  31. package/dist/__tests__/features/rendering.spec.d.ts +0 -1
  32. package/dist/__tests__/shared/render.shared.d.ts +0 -11
  33. package/dist/__tests__/utils/controls.utils.d.ts +0 -3
  34. package/dist/__tests__/utils/example.d.ts +0 -6
  35. package/dist/src/components/index.d.ts +0 -4
  36. package/dist/src/components/keep-scale/keep-scale.d.ts +0 -2
  37. package/dist/src/components/mini-map/mini-map.d.ts +0 -8
  38. package/dist/src/components/mini-map/use-resize.hook.d.ts +0 -8
  39. package/dist/src/components/transform-component/transform-component.d.ts +0 -12
  40. package/dist/src/components/transform-wrapper/transform-wrapper.d.ts +0 -5
  41. package/dist/src/constants/state.constants.d.ts +0 -3
  42. package/dist/src/core/animations/animations.constants.d.ts +0 -16
  43. package/dist/src/core/animations/animations.utils.d.ts +0 -4
  44. package/dist/src/core/bounds/bounds.types.d.ts +0 -8
  45. package/dist/src/core/bounds/bounds.utils.d.ts +0 -17
  46. package/dist/src/core/double-click/double-click.logic.d.ts +0 -5
  47. package/dist/src/core/handlers/handlers.logic.d.ts +0 -8
  48. package/dist/src/core/handlers/handlers.utils.d.ts +0 -14
  49. package/dist/src/core/instance.core.d.ts +0 -77
  50. package/dist/src/core/pan/panning.logic.d.ts +0 -5
  51. package/dist/src/core/pan/panning.utils.d.ts +0 -10
  52. package/dist/src/core/pan/velocity.logic.d.ts +0 -5
  53. package/dist/src/core/pan/velocity.utils.d.ts +0 -5
  54. package/dist/src/core/pinch/pinch.logic.d.ts +0 -4
  55. package/dist/src/core/pinch/pinch.utils.d.ts +0 -6
  56. package/dist/src/core/wheel/wheel.logic.d.ts +0 -4
  57. package/dist/src/core/wheel/wheel.utils.d.ts +0 -7
  58. package/dist/src/core/zoom/zoom.logic.d.ts +0 -3
  59. package/dist/src/core/zoom/zoom.utils.d.ts +0 -3
  60. package/dist/src/hooks/index.d.ts +0 -4
  61. package/dist/src/hooks/use-controls.d.ts +0 -2
  62. package/dist/src/hooks/use-transform-context.d.ts +0 -1
  63. package/dist/src/hooks/use-transform-effect.d.ts +0 -2
  64. package/dist/src/hooks/use-transform-init.d.ts +0 -2
  65. package/dist/src/index.d.ts +0 -5
  66. package/dist/src/models/calculations.model.d.ts +0 -25
  67. package/dist/src/models/context.model.d.ts +0 -124
  68. package/dist/src/models/helpers.model.d.ts +0 -5
  69. package/dist/src/models/index.d.ts +0 -3
  70. package/dist/src/stories/docs/handlers.d.ts +0 -12
  71. package/dist/src/stories/docs/props.d.ts +0 -14
  72. package/dist/src/stories/examples/content-rerendering/example.d.ts +0 -2
  73. package/dist/src/stories/examples/image-responsive/example.d.ts +0 -2
  74. package/dist/src/stories/examples/keep-scale/example.d.ts +0 -2
  75. package/dist/src/stories/examples/mini-map/example.d.ts +0 -1
  76. package/dist/src/stories/examples/stress/example.d.ts +0 -2
  77. package/dist/src/stories/examples/svg-zoom-to-element/example.d.ts +0 -2
  78. package/dist/src/stories/examples/zoom-to-element/example.d.ts +0 -2
  79. package/dist/src/stories/types/args.types.d.ts +0 -280
  80. package/dist/src/stories/utils/args.utils.d.ts +0 -3
  81. package/dist/src/stories/utils/code.utils.d.ts +0 -6
  82. package/dist/src/stories/utils/controls.utils.d.ts +0 -3
  83. package/dist/src/stories/utils/index.d.ts +0 -3
  84. package/dist/src/utils/calculations.utils.d.ts +0 -11
  85. package/dist/src/utils/callback.utils.d.ts +0 -2
  86. package/dist/src/utils/context.utils.d.ts +0 -4
  87. package/dist/src/utils/event.utils.d.ts +0 -1
  88. package/dist/src/utils/helpers.utils.d.ts +0 -2
  89. package/dist/src/utils/index.d.ts +0 -8
  90. package/dist/src/utils/ref.utils.d.ts +0 -2
  91. package/dist/src/utils/state.utils.d.ts +0 -3
  92. package/dist/src/utils/styles.utils.d.ts +0 -4
  93. package/jest.config.ts +0 -45
  94. package/rollup.config.js +0 -51
  95. package/src/.eslintrc.json +0 -90
  96. package/src/components/index.ts +0 -4
  97. package/src/components/keep-scale/keep-scale.tsx +0 -28
  98. package/src/components/mini-map/mini-map.tsx +0 -188
  99. package/src/components/mini-map/use-resize.hook.ts +0 -69
  100. package/src/components/transform-component/transform-component.module.css +0 -30
  101. package/src/components/transform-component/transform-component.tsx +0 -58
  102. package/src/components/transform-wrapper/transform-wrapper.tsx +0 -42
  103. package/src/constants/state.constants.ts +0 -74
  104. package/src/core/animations/animations.constants.ts +0 -78
  105. package/src/core/animations/animations.utils.ts +0 -114
  106. package/src/core/bounds/bounds.types.ts +0 -8
  107. package/src/core/bounds/bounds.utils.ts +0 -198
  108. package/src/core/double-click/double-click.logic.ts +0 -116
  109. package/src/core/handlers/handlers.logic.ts +0 -115
  110. package/src/core/handlers/handlers.utils.ts +0 -195
  111. package/src/core/instance.core.ts +0 -499
  112. package/src/core/pan/panning.logic.ts +0 -100
  113. package/src/core/pan/panning.utils.ts +0 -196
  114. package/src/core/pan/velocity.logic.ts +0 -149
  115. package/src/core/pan/velocity.utils.ts +0 -79
  116. package/src/core/pinch/pinch.logic.ts +0 -81
  117. package/src/core/pinch/pinch.utils.ts +0 -88
  118. package/src/core/wheel/wheel.logic.ts +0 -121
  119. package/src/core/wheel/wheel.utils.ts +0 -122
  120. package/src/core/zoom/zoom.logic.ts +0 -69
  121. package/src/core/zoom/zoom.utils.ts +0 -58
  122. package/src/hooks/index.ts +0 -4
  123. package/src/hooks/use-controls.tsx +0 -9
  124. package/src/hooks/use-transform-context.tsx +0 -13
  125. package/src/hooks/use-transform-effect.tsx +0 -22
  126. package/src/hooks/use-transform-init.tsx +0 -27
  127. package/src/index.ts +0 -6
  128. package/src/models/calculations.model.ts +0 -26
  129. package/src/models/context.model.ts +0 -196
  130. package/src/models/helpers.model.ts +0 -15
  131. package/src/models/index.ts +0 -3
  132. package/src/react-app-env.d.ts +0 -1
  133. package/src/stories/assets/big-image.jpeg +0 -0
  134. package/src/stories/assets/map.jpg +0 -0
  135. package/src/stories/assets/medium-image.jpg +0 -0
  136. package/src/stories/assets/pin.svg +0 -1
  137. package/src/stories/assets/small-image.jpg +0 -0
  138. package/src/stories/assets/svg-example.svg +0 -14
  139. package/src/stories/docs/Introduction.stories.mdx +0 -174
  140. package/src/stories/docs/handlers.stories.mdx +0 -48
  141. package/src/stories/docs/handlers.tsx +0 -107
  142. package/src/stories/docs/props.stories.mdx +0 -92
  143. package/src/stories/docs/props.tsx +0 -508
  144. package/src/stories/examples/content/content.stories.mdx +0 -121
  145. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +0 -45
  146. package/src/stories/examples/content-rerendering/example.tsx +0 -73
  147. package/src/stories/examples/controls/controls.stories.mdx +0 -71
  148. package/src/stories/examples/image-big/image-big.stories.mdx +0 -43
  149. package/src/stories/examples/image-medium/image-medium.stories.mdx +0 -41
  150. package/src/stories/examples/image-responsive/example.tsx +0 -103
  151. package/src/stories/examples/image-responsive/image-responsive.stories.mdx +0 -32
  152. package/src/stories/examples/image-small/image-small.stories.mdx +0 -41
  153. package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +0 -46
  154. package/src/stories/examples/keep-scale/example.tsx +0 -92
  155. package/src/stories/examples/keep-scale/keep-scale.stories.mdx +0 -45
  156. package/src/stories/examples/mini-map/example.tsx +0 -54
  157. package/src/stories/examples/mini-map/mini-map.stories.mdx +0 -33
  158. package/src/stories/examples/stress/example.tsx +0 -23
  159. package/src/stories/examples/stress/stress-test.stories.mdx +0 -28
  160. package/src/stories/examples/svg-zoom-to-element/creativity.svg +0 -143
  161. package/src/stories/examples/svg-zoom-to-element/example.tsx +0 -57
  162. package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +0 -28
  163. package/src/stories/examples/zoom-to-element/example.tsx +0 -94
  164. package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +0 -28
  165. package/src/stories/hooks/use-controls.stories.mdx +0 -24
  166. package/src/stories/hooks/use-transform-context.stories.mdx +0 -15
  167. package/src/stories/hooks/use-transform-effect.stories.mdx +0 -29
  168. package/src/stories/hooks/use-transform-init.stories.mdx +0 -25
  169. package/src/stories/types/args.types.ts +0 -211
  170. package/src/stories/utils/args.utils.ts +0 -34
  171. package/src/stories/utils/code.utils.tsx +0 -24
  172. package/src/stories/utils/controls.utils.tsx +0 -43
  173. package/src/stories/utils/index.ts +0 -3
  174. package/src/stories/utils/styles.module.css +0 -34
  175. package/src/styles.css +0 -8
  176. package/src/typings.d.ts +0 -10
  177. package/src/utils/calculations.utils.ts +0 -16
  178. package/src/utils/callback.utils.ts +0 -11
  179. package/src/utils/context.utils.ts +0 -48
  180. package/src/utils/event.utils.ts +0 -22
  181. package/src/utils/helpers.utils.ts +0 -27
  182. package/src/utils/index.ts +0 -8
  183. package/src/utils/ref.utils.ts +0 -16
  184. package/src/utils/state.utils.ts +0 -40
  185. package/src/utils/styles.utils.ts +0 -44
  186. package/tsconfig.json +0 -33
package/Contributing.md DELETED
@@ -1,236 +0,0 @@
1
- <!-- omit in toc -->
2
-
3
- # Contributing to Zoom Pan Pinch
4
-
5
- First off, thanks for taking the time to contribute! ❤️
6
-
7
- All types of contributions are encouraged and valued. See the
8
- [Table of Contents](#table-of-contents) for different ways to help and details
9
- about how this project handles them. Please make sure to read the relevant
10
- section before making your contribution. It will make it a lot easier for us
11
- maintainers and smooth out the experience for all involved. The community looks
12
- forward to your contributions. 🎉
13
-
14
- > And if you like the project, but just don't have time to contribute, that's
15
- > fine. There are other easy ways to support the project and show your
16
- > appreciation, which we would also be very happy about:
17
- >
18
- > - Star the project
19
- > - Tweet about it
20
- > - Refer this project in your project's readme
21
- > - Mention the project at local meetups and tell your friends/colleagues
22
-
23
- <!-- omit in toc -->
24
-
25
- ## Table of Contents
26
-
27
- - [Contributing to Zoom Pan Pinch](#contributing-to-zoom-pan-pinch)
28
- - [Table of Contents](#table-of-contents)
29
- - [I Have a Question](#i-have-a-question)
30
- - [I Want To Contribute](#i-want-to-contribute)
31
- - [Reporting Bugs](#reporting-bugs)
32
- - [Before Submitting a Bug Report](#before-submitting-a-bug-report)
33
- - [How Do I Submit a Good Bug Report?](#how-do-i-submit-a-good-bug-report)
34
- - [Suggesting Enhancements](#suggesting-enhancements)
35
- - [Before Submitting an Enhancement](#before-submitting-an-enhancement)
36
- - [How Do I Submit a Good Enhancement Suggestion?](#how-do-i-submit-a-good-enhancement-suggestion)
37
- - [Your First Code Contribution](#your-first-code-contribution)
38
- - [Improving The Documentation](#improving-the-documentation)
39
- - [Styleguides](#styleguides)
40
- - [Commit Messages](#commit-messages)
41
- - [Join The Project Team](#join-the-project-team)
42
- - [Attribution](#attribution)
43
-
44
- ## I Have a Question
45
-
46
- > If you want to ask a question, we assume that you have read the available
47
- > [Documentation](https://prc5.github.io/react-zoom-pan-pinch/).
48
-
49
- Before you ask a question, it is best to search for existing
50
- [Issues](https://github.com/prc5/react-zoom-pan-pinch/issues) that might help
51
- you. In case you have found a suitable issue and still need clarification, you
52
- can write your question in this issue. It is also advisable to search the
53
- internet for answers first.
54
-
55
- If you then still feel the need to ask a question and need clarification, we
56
- recommend the following:
57
-
58
- - Open an [Issue](https://github.com/prc5/react-zoom-pan-pinch/issues/new).
59
- - Provide as much context as you can about what you're running into.
60
- - Provide project and platform versions (nodejs, npm, etc), depending on what
61
- seems relevant.
62
-
63
- We will then take care of the issue as soon as possible.
64
-
65
- <!--
66
- You might want to create a separate issue tag for questions and include it in this description. People should then tag their issues accordingly.
67
-
68
- Depending on how large the project is, you may want to outsource the questioning, e.g. to Stack Overflow or Gitter. You may add additional contact and information possibilities:
69
- - IRC
70
- - Slack
71
- - Gitter
72
- - Stack Overflow tag
73
- - Blog
74
- - FAQ
75
- - Roadmap
76
- - E-Mail List
77
- - Forum
78
- -->
79
-
80
- ## I Want To Contribute
81
-
82
- > ### Legal Notice <!-- omit in toc -->
83
- >
84
- > When contributing to this project, you must agree that you have authored 100%
85
- > of the content, that you have the necessary rights to the content and that the
86
- > content you contribute may be provided under the project license.
87
-
88
- ### Reporting Bugs
89
-
90
- <!-- omit in toc -->
91
-
92
- #### Before Submitting a Bug Report
93
-
94
- A good bug report shouldn't leave others needing to chase you up for more
95
- information. Therefore, we ask you to investigate carefully, collect information
96
- and describe the issue in detail in your report. Please complete the following
97
- steps in advance to help us fix any potential bug as fast as possible.
98
-
99
- - Make sure that you are using the latest version.
100
- - Determine if your bug is really a bug and not an error on your side e.g. using
101
- incompatible environment components/versions (Make sure that you have read the
102
- [documentation](https://prc5.github.io/react-zoom-pan-pinch/). If you are
103
- looking for support, you might want to check
104
- [this section](#i-have-a-question)).
105
- - To see if other users have experienced (and potentially already solved) the
106
- same issue you are having, check if there is not already a bug report existing
107
- for your bug or error in the
108
- [bug tracker](https://github.com/prc5/react-zoom-pan-pinchissues?q=label%3Abug).
109
- - Also make sure to search the internet (including Stack Overflow) to see if
110
- users outside of the GitHub community have discussed the issue.
111
- - Collect information about the bug:
112
- - Stack trace (Traceback)
113
- - OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
114
- - Version of the interpreter, compiler, SDK, runtime environment, package
115
- manager, depending on what seems relevant.
116
- - Possibly your input and the output
117
- - Can you reliably reproduce the issue? And can you also reproduce it with older
118
- versions?
119
-
120
- <!-- omit in toc -->
121
-
122
- #### How Do I Submit a Good Bug Report?
123
-
124
- > You must never report security related issues, vulnerabilities or bugs
125
- > including sensitive information to the issue tracker, or elsewhere in public.
126
- > Instead sensitive bugs must be sent by email to <>.
127
-
128
- <!-- You may add a PGP key to allow the messages to be sent encrypted as well. -->
129
-
130
- We use GitHub issues to track bugs and errors. If you run into an issue with the
131
- project:
132
-
133
- - Open an [Issue](https://github.com/prc5/react-zoom-pan-pinch/issues/new).
134
- (Since we can't be sure at this point whether it is a bug or not, we ask you
135
- not to talk about a bug yet and not to label the issue.)
136
- - Explain the behavior you would expect and the actual behavior.
137
- - Please provide as much context as possible and describe the _reproduction
138
- steps_ that someone else can follow to recreate the issue on their own. This
139
- usually includes your code. For good bug reports you should isolate the
140
- problem and create a reduced test case.
141
- - Provide the information you collected in the previous section.
142
-
143
- Once it's filed:
144
-
145
- - The project team will label the issue accordingly.
146
- - A team member will try to reproduce the issue with your provided steps. If
147
- there are no reproduction steps or no obvious way to reproduce the issue, the
148
- team will ask you for those steps and mark the issue as `needs-repro`. Bugs
149
- with the `needs-repro` tag will not be addressed until they are reproduced.
150
- - If the team is able to reproduce the issue, it will be marked `needs-fix`, as
151
- well as possibly other tags (such as `critical`), and the issue will be left
152
- to be [implemented by someone](#your-first-code-contribution).
153
-
154
- <!-- You might want to create an issue template for bugs and errors that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->
155
-
156
- ### Suggesting Enhancements
157
-
158
- This section guides you through submitting an enhancement suggestion for Zoom
159
- Pan Pinch, **including completely new features and minor improvements to
160
- existing functionality**. Following these guidelines will help maintainers and
161
- the community to understand your suggestion and find related suggestions.
162
-
163
- <!-- omit in toc -->
164
-
165
- #### Before Submitting an Enhancement
166
-
167
- - Make sure that you are using the latest version.
168
- - Read the [documentation](https://prc5.github.io/react-zoom-pan-pinch/)
169
- carefully and find out if the functionality is already covered, maybe by an
170
- individual configuration.
171
- - Perform a [search](https://github.com/prc5/react-zoom-pan-pinch/issues) to see
172
- if the enhancement has already been suggested. If it has, add a comment to the
173
- existing issue instead of opening a new one.
174
- - Find out whether your idea fits with the scope and aims of the project. It's
175
- up to you to make a strong case to convince the project's developers of the
176
- merits of this feature. Keep in mind that we want features that will be useful
177
- to the majority of our users and not just a small subset. If you're just
178
- targeting a minority of users, consider writing an add-on/plugin library.
179
-
180
- <!-- omit in toc -->
181
-
182
- #### How Do I Submit a Good Enhancement Suggestion?
183
-
184
- Enhancement suggestions are tracked as
185
- [GitHub issues](https://github.com/prc5/react-zoom-pan-pinch/issues).
186
-
187
- - Use a **clear and descriptive title** for the issue to identify the
188
- suggestion.
189
- - Provide a **step-by-step description of the suggested enhancement** in as many
190
- details as possible.
191
- - **Describe the current behavior** and **explain which behavior you expected to
192
- see instead** and why. At this point you can also tell which alternatives do
193
- not work for you.
194
- - You may want to **include screenshots and animated GIFs** which help you
195
- demonstrate the steps or point out the part which the suggestion is related
196
- to.
197
- - **Explain why this enhancement would be useful** to most Zoom Pan Pinch users.
198
- You may also want to point out the other projects that solved it better and
199
- which could serve as inspiration.
200
-
201
- ### Your First Code Contribution
202
-
203
- Checkout
204
- [this tutorial](https://github.com/firstcontributions/first-contributions) of
205
- how to contribute to any project.
206
-
207
- ### Improving The Documentation
208
-
209
- Anyone can help improve the documentation - it is in this repository and is
210
- available to everyone - if you have an idea how to improve it - send us a pull
211
- request and we will try to consider it as soon as possible!
212
-
213
- ## Styleguides
214
-
215
- Each contribution must meet the conditions of our linter and formatter. When
216
- these criteria are not met, the creator will get the appropriate status from
217
- github actions, if issues are not corrected within two weeks, the pull request
218
- will be rejected and closed immediately.
219
-
220
- ### Commit Messages
221
-
222
- Commit messages must follow the
223
- [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard
224
- and present the best possible description of the changes made, which will later
225
- be automatically placed in the release notes. They must not contain curses or
226
- offensive sentences.
227
-
228
- ## Join The Project Team
229
-
230
- Do you want to have a greater impact on the development of the library? Get in
231
- touch with us!
232
-
233
- ## Attribution
234
-
235
- This guide is based on the **contributing-gen**.
236
- [Make your own](https://github.com/bttger/contributing-gen)!
@@ -1,11 +0,0 @@
1
- import { renderExample } from "../shared/render.shared";
2
-
3
- describe("Library components", () => {
4
- describe("When library components have been rendered", () => {
5
- test("it renders transform component without errors", () => {
6
- const { content, wrapper } = renderExample();
7
- expect(content).toBeDefined();
8
- expect(wrapper).toBeDefined();
9
- });
10
- });
11
- });
@@ -1,36 +0,0 @@
1
- import { renderExample } from "../shared/render.shared";
2
-
3
- describe("Example view", () => {
4
- describe("When example view has been rendered", () => {
5
- test("it renders entire example without errors", () => {
6
- const { wrapper } = renderExample();
7
-
8
- expect(wrapper).toBeDefined();
9
- });
10
- test("it renders center in button without errors", () => {
11
- const { center } = renderExample();
12
-
13
- expect(center).toBeDefined();
14
- });
15
- test("it renders zoom in button without errors", () => {
16
- const { zoomInBtn } = renderExample();
17
-
18
- expect(zoomInBtn).toBeDefined();
19
- });
20
- test("it renders zoom out button without errors", () => {
21
- const { zoomOutBtn } = renderExample();
22
-
23
- expect(zoomOutBtn).toBeDefined();
24
- });
25
- test("it renders reset button without errors", () => {
26
- const { resetBtn } = renderExample();
27
-
28
- expect(resetBtn).toBeDefined();
29
- });
30
- test("it renders transform component without errors", () => {
31
- const { content } = renderExample();
32
-
33
- expect(content).toBeDefined();
34
- });
35
- });
36
- });
@@ -1,41 +0,0 @@
1
- import React from "react";
2
- import { render, screen } from "@testing-library/react";
3
-
4
- import { ReactZoomPanPinchProps } from "../../src";
5
- import { Example } from "../utils/example";
6
-
7
- export const renderExample = (props?: ReactZoomPanPinchProps) => {
8
- let renders = 0;
9
- let renderPropsValues = {};
10
-
11
- render(
12
- <Example
13
- {...props}
14
- onRender={() => {
15
- renders += 1;
16
- }}
17
- onRenderProps={(ref) => {
18
- renderPropsValues = ref;
19
- }}
20
- />,
21
- );
22
- // controls buttons
23
- const zoomInBtn = screen.getByTestId("zoom-in");
24
- const zoomOutBtn = screen.getByTestId("zoom-out");
25
- const resetBtn = screen.getByTestId("reset");
26
- const center = screen.getByTestId("center");
27
- // containers
28
- const content = screen.getByTestId("content");
29
- const wrapper = screen.getByTestId("wrapper");
30
-
31
- return {
32
- renders,
33
- renderPropsValues,
34
- zoomInBtn,
35
- zoomOutBtn,
36
- resetBtn,
37
- center,
38
- content,
39
- wrapper,
40
- };
41
- };
@@ -1,25 +0,0 @@
1
- import React from "react";
2
-
3
- import { ReactZoomPanPinchContentRef } from "../../src";
4
-
5
- export const Controls: React.FC<ReactZoomPanPinchContentRef> = ({
6
- zoomIn,
7
- zoomOut,
8
- resetTransform,
9
- centerView,
10
- }: ReactZoomPanPinchContentRef) => (
11
- <div>
12
- <button type="button" onClick={() => zoomIn()} data-testid="zoom-in">
13
- Zoom In +
14
- </button>
15
- <button type="button" onClick={() => zoomOut()} data-testid="zoom-out">
16
- Zoom Out -
17
- </button>
18
- <button type="button" onClick={() => resetTransform()} data-testid="reset">
19
- Reset
20
- </button>
21
- <button type="button" onClick={() => centerView()} data-testid="center">
22
- Center
23
- </button>
24
- </div>
25
- );
@@ -1,81 +0,0 @@
1
- import React from "react";
2
-
3
- import {
4
- TransformWrapper,
5
- TransformComponent,
6
- ReactZoomPanPinchProps,
7
- ReactZoomPanPinchContentRef,
8
- } from "../../src";
9
- import { Controls } from "./controls.utils";
10
-
11
- export const Example = (options: {
12
- props?: ReactZoomPanPinchProps;
13
- onRender: () => void;
14
- onRenderProps: (ref: ReactZoomPanPinchContentRef) => void;
15
- }) => {
16
- const { props = {}, onRender, onRenderProps } = options;
17
-
18
- onRender();
19
-
20
- return (
21
- <TransformWrapper {...props}>
22
- {(utils) => (
23
- <div>
24
- {onRenderProps(utils)}
25
- <Controls {...utils} />
26
- <TransformComponent
27
- wrapperProps={
28
- {
29
- "data-testid": "wrapper",
30
- } as React.HTMLAttributes<HTMLDivElement>
31
- }
32
- contentProps={
33
- {
34
- "data-testid": "content",
35
- } as React.HTMLAttributes<HTMLDivElement>
36
- }
37
- wrapperStyle={{
38
- width: "500px",
39
- height: "500px",
40
- maxWidth: "100%",
41
- maxHeight: "calc(100vh - 50px)",
42
- }}
43
- >
44
- <div
45
- style={{ background: "#444", color: "white", padding: "50px" }}
46
- >
47
- <h1>Title</h1>
48
- <h2>Subtitle</h2>
49
- <button
50
- type="button"
51
- onClick={() =>
52
- alert("You can still interact with click events!")
53
- }
54
- >
55
- Click me!
56
- </button>
57
- <p>
58
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
59
- eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
60
- enim ad minim veniam, quis nostrud exercitation ullamco laboris
61
- nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
62
- in reprehenderit in voluptate velit esse cillum dolore eu fugiat
63
- nulla pariatur. Excepteur sint occaecat cupidatat non proident,
64
- sunt in culpa qui officia deserunt mollit anim id est laborum
65
- </p>
66
- <p>
67
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
68
- eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
69
- enim ad minim veniam, quis nostrud exercitation ullamco laboris
70
- nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
71
- in reprehenderit in voluptate velit esse cillum dolore eu fugiat
72
- nulla pariatur. Excepteur sint occaecat cupidatat non proident,
73
- sunt in culpa qui officia deserunt mollit anim id est laborum
74
- </p>
75
- </div>
76
- </TransformComponent>
77
- </div>
78
- )}
79
- </TransformWrapper>
80
- );
81
- };
@@ -1 +0,0 @@
1
- module.exports = { extends: ["@commitlint/config-conventional"] };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { ReactZoomPanPinchProps } from "../../src";
2
- export declare const renderExample: (props?: ReactZoomPanPinchProps) => {
3
- renders: number;
4
- renderPropsValues: {};
5
- zoomInBtn: HTMLElement;
6
- zoomOutBtn: HTMLElement;
7
- resetBtn: HTMLElement;
8
- center: HTMLElement;
9
- content: HTMLElement;
10
- wrapper: HTMLElement;
11
- };
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import { ReactZoomPanPinchContentRef } from "../../src";
3
- export declare const Controls: React.FC<ReactZoomPanPinchContentRef>;
@@ -1,6 +0,0 @@
1
- import { ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from "../../src";
2
- export declare const Example: (options: {
3
- props?: ReactZoomPanPinchProps | undefined;
4
- onRender: () => void;
5
- onRenderProps: (ref: ReactZoomPanPinchContentRef) => void;
6
- }) => JSX.Element;
@@ -1,4 +0,0 @@
1
- export * from "./keep-scale/keep-scale";
2
- export * from "./mini-map/mini-map";
3
- export * from "./transform-component/transform-component";
4
- export * from "./transform-wrapper/transform-wrapper";
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const KeepScale: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- export type MiniMapProps = {
3
- children: React.ReactNode;
4
- width?: number;
5
- height?: number;
6
- borderColor?: string;
7
- } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
8
- export declare const MiniMap: React.FC<MiniMapProps>;
@@ -1,8 +0,0 @@
1
- export type NonNullableKeys<T> = {
2
- [P in keyof T]-?: NonNullable<T[P]>;
3
- };
4
- export type Nullable<T> = T | null;
5
- export type ElementRect = Omit<DOMRect, "toJSON">;
6
- type ResizeHandler<T extends HTMLElement> = (elementRect: ElementRect, element: T) => void;
7
- export declare const useResize: <T extends HTMLElement>(ref: Nullable<T>, onResize: ResizeHandler<T>, dependencies: any[]) => void;
8
- export {};
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- type Props = {
3
- children: React.ReactNode;
4
- wrapperClass?: string;
5
- contentClass?: string;
6
- wrapperStyle?: React.CSSProperties;
7
- contentStyle?: React.CSSProperties;
8
- wrapperProps?: React.HTMLAttributes<HTMLDivElement>;
9
- contentProps?: React.HTMLAttributes<HTMLDivElement>;
10
- };
11
- export declare const TransformComponent: React.FC<Props>;
12
- export {};
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { ZoomPanPinch } from "../../core/instance.core";
3
- import { ReactZoomPanPinchContentRef, ReactZoomPanPinchProps } from "../../models";
4
- export declare const Context: React.Context<ZoomPanPinch>;
5
- export declare const TransformWrapper: React.ForwardRefExoticComponent<Omit<ReactZoomPanPinchProps, "ref"> & React.RefAttributes<ReactZoomPanPinchContentRef>>;
@@ -1,3 +0,0 @@
1
- import { LibrarySetup, ReactZoomPanPinchState } from "../models/context.model";
2
- export declare const initialState: ReactZoomPanPinchState;
3
- export declare const initialSetup: LibrarySetup;
@@ -1,16 +0,0 @@
1
- export declare const animations: {
2
- easeOut: (t: number) => number;
3
- linear: (t: number) => number;
4
- easeInQuad: (t: number) => number;
5
- easeOutQuad: (t: number) => number;
6
- easeInOutQuad: (t: number) => number;
7
- easeInCubic: (t: number) => number;
8
- easeOutCubic: (t: number) => number;
9
- easeInOutCubic: (t: number) => number;
10
- easeInQuart: (t: number) => number;
11
- easeOutQuart: (t: number) => number;
12
- easeInOutQuart: (t: number) => number;
13
- easeInQuint: (t: number) => number;
14
- easeOutQuint: (t: number) => number;
15
- easeInOutQuint: (t: number) => number;
16
- };
@@ -1,4 +0,0 @@
1
- import { ReactZoomPanPinchContext, StateType } from "../../models";
2
- export declare const handleCancelAnimation: (contextInstance: ReactZoomPanPinchContext) => void;
3
- export declare function handleSetupAnimation(contextInstance: ReactZoomPanPinchContext, animationName: string, animationTime: number, callback: (step: number) => void): void;
4
- export declare function animate(contextInstance: ReactZoomPanPinchContext, targetState: StateType, animationTime: number, animationName: string): void;
@@ -1,8 +0,0 @@
1
- export type ComponentsSizesType = {
2
- wrapperWidth: number;
3
- wrapperHeight: number;
4
- newContentWidth: number;
5
- newDiffWidth: number;
6
- newContentHeight: number;
7
- newDiffHeight: number;
8
- };
@@ -1,17 +0,0 @@
1
- import { BoundsType, PositionType, ReactZoomPanPinchContext } from "../../models";
2
- import { ComponentsSizesType } from "./bounds.types";
3
- export declare function getComponentsSizes(wrapperComponent: HTMLDivElement, contentComponent: HTMLDivElement, newScale: number): ComponentsSizesType;
4
- export declare const getBounds: (wrapperWidth: number, newContentWidth: number, diffWidth: number, wrapperHeight: number, newContentHeight: number, diffHeight: number, centerZoomedOut: boolean) => BoundsType;
5
- export declare const calculateBounds: (contextInstance: ReactZoomPanPinchContext, newScale: number) => BoundsType;
6
- export declare function clamp(v: number, min: number, max: number): number;
7
- export declare function rubberbandIfOutOfBounds(position: number, min: number, max: number, constant?: number): number;
8
- /**
9
- * Keeps value between given bounds, used for limiting view to given boundaries
10
- * 1# eg. boundLimiter(2, 0, 3, true) => 2
11
- * 2# eg. boundLimiter(4, 0, 3, true) => 3
12
- * 3# eg. boundLimiter(-2, 0, 3, true) => 0
13
- * 4# eg. boundLimiter(10, 0, 3, false) => 10
14
- */
15
- export declare const boundLimiter: (value: number, minBound: number, maxBound: number, isActive: boolean) => number;
16
- export declare const handleCalculateBounds: (contextInstance: ReactZoomPanPinchContext, newScale: number) => BoundsType;
17
- export declare function getMouseBoundedPosition(positionX: number, positionY: number, bounds: BoundsType, limitToBounds: boolean, paddingValueX: number, paddingValueY: number, wrapperComponent: HTMLDivElement | null): PositionType;
@@ -1,5 +0,0 @@
1
- import { ReactZoomPanPinchContext } from "../../models";
2
- export declare const handleDoubleClickStop: (contextInstance: ReactZoomPanPinchContext, event: MouseEvent | TouchEvent) => void;
3
- export declare const handleDoubleClickResetMode: (contextInstance: ReactZoomPanPinchContext, event: MouseEvent | TouchEvent) => void;
4
- export declare function handleDoubleClick(contextInstance: ReactZoomPanPinchContext, event: MouseEvent | TouchEvent): void;
5
- export declare const isDoubleClickAllowed: (contextInstance: ReactZoomPanPinchContext, event: MouseEvent | TouchEvent) => boolean;
@@ -1,8 +0,0 @@
1
- import { ReactZoomPanPinchContext } from "../../models";
2
- import { animations } from "../animations/animations.constants";
3
- export declare const zoomIn: (contextInstance: ReactZoomPanPinchContext) => (step?: number, animationTime?: number, animationType?: keyof typeof animations) => void;
4
- export declare const zoomOut: (contextInstance: ReactZoomPanPinchContext) => (step?: number, animationTime?: number, animationType?: keyof typeof animations) => void;
5
- export declare const setTransform: (contextInstance: ReactZoomPanPinchContext) => (newPositionX: number, newPositionY: number, newScale: number, animationTime?: number, animationType?: keyof typeof animations) => void;
6
- export declare const resetTransform: (contextInstance: ReactZoomPanPinchContext) => (animationTime?: number, animationType?: keyof typeof animations) => void;
7
- export declare const centerView: (contextInstance: ReactZoomPanPinchContext) => (scale?: number, animationTime?: number, animationType?: keyof typeof animations) => void;
8
- export declare const zoomToElement: (contextInstance: ReactZoomPanPinchContext) => (node: HTMLElement | string, scale?: number, animationTime?: number, animationType?: keyof typeof animations) => void;
@@ -1,14 +0,0 @@
1
- import { ReactZoomPanPinchContext, ReactZoomPanPinchState } from "../../models";
2
- import { animations } from "../animations/animations.constants";
3
- export declare const handleCalculateButtonZoom: (contextInstance: ReactZoomPanPinchContext, delta: number, step: number) => number;
4
- export declare function handleZoomToViewCenter(contextInstance: ReactZoomPanPinchContext, delta: number, step: number, animationTime: number, animationType: keyof typeof animations): void;
5
- export declare function resetTransformations(contextInstance: ReactZoomPanPinchContext, animationTime: number, animationType: keyof typeof animations, onResetTransformation?: () => void): void;
6
- export declare function getOffset(element: HTMLElement, wrapper: HTMLElement, content: HTMLElement, state: ReactZoomPanPinchState): {
7
- x: number;
8
- y: number;
9
- };
10
- export declare function calculateZoomToNode(contextInstance: ReactZoomPanPinchContext, node: HTMLElement, customZoom?: number): {
11
- positionX: number;
12
- positionY: number;
13
- scale: number;
14
- };