Skip to content

Commit 2cbe822

Browse files
authored
Merge pull request #124 from Glazzes/dev
Release 6.0.0
2 parents 4aae7d8 + 91bfa00 commit 2cbe822

71 files changed

Lines changed: 9211 additions & 11287 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ project.xcworkspace
4040
local.properties
4141
android.iml
4242

43-
# Cocoapods
44-
#
45-
example/ios/Pods
43+
# Native files
44+
example/ios/
45+
example/android/
4646

4747
# Ruby
4848
example/vendor/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18
1+
v24

babel.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
module.exports = {
22
presets: ['module:@react-native/babel-preset'],
3-
plugins: [
4-
'@babel/plugin-proposal-export-namespace-from',
5-
'react-native-reanimated/plugin',
6-
],
3+
plugins: ['react-native-worklets/plugin'],
74
};

docs/docs/.vitepress/config.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig({
1414
nav: [
1515
{ text: 'Home', link: '/' },
1616
{
17-
text: '5.0.0',
17+
text: '5.1.0',
1818
items: [
1919
{
2020
text: 'Releases',
@@ -52,6 +52,10 @@ export default defineConfig({
5252
text: 'useTransformationState',
5353
link: '/utilities/usetransformationstate',
5454
},
55+
{
56+
text: 'useZoomCallbacks',
57+
link: '/utilities/useZoomCallbacks',
58+
},
5559
],
5660
},
5761
{

docs/docs/components/gallery.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,36 @@ Blank space between items.
176176
| -------- | ------- |
177177
| `number` | `0` |
178178

179-
Sets the initial position of the list.
179+
Set the initial position of the list.
180+
181+
### rtl
182+
| Type | Default |
183+
| --------- | ------- |
184+
| `boolean` | `false` |
185+
186+
Enable support for right to left layouts on horizontal mode, [more info](https://github.com/Glazzes/react-native-zoom-toolkit/issues/99#issuecomment-3029442065).
180187

181188
### vertical
182189

183190
| Type | Default |
184191
| --------- | ------- |
185192
| `boolean` | `false` |
186193

187-
Modifies the orientation of the component to vertical mode.
194+
Modify the orientation of the component to vertical mode.
195+
196+
### snapTimingConfig
197+
198+
| Type | Default | Adittional Info |
199+
| -------- | ------------| --------------- |
200+
| `object` | `{duration: 300, easing: Easing.out(Easing.cubic)}` | see [timingConfig](https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming/#config-) |
201+
202+
Set the timing config used to snap between gallery's elements.
188203

189204
### maxScale
190205

191206
| Type | Default |
192207
| -------------------------------- | ------- |
193-
| `SizeVector<number>[] \| number` | `6` |
208+
| `Size<number>[] \| number` | `6` |
194209

195210
Maximum scale value allowed by the pinch gesture for all elements, expects values bigger than or equals one.
196211

@@ -288,6 +303,22 @@ Callback triggered when the list scrolls to the next or previous item.
288303

289304
Callback triggered when the user taps the current item once, provides additional metadata like index if you need it.
290305

306+
### onDoubleTapStart
307+
308+
| Type | Default | Additional Info |
309+
| ------------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------- |
310+
| `(e: TapGestureEvent) => void` | `undefined` | see [tap gesture event data](https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#event-data) |
311+
312+
Callback triggered when the user double taps.
313+
314+
### onDoubleTapEnd
315+
316+
| Type | Default | Additional Info |
317+
| ------------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------- |
318+
| `(e: TapGestureEvent) => void` | `undefined` | see [tap gesture event data](https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#event-data) |
319+
320+
Callback triggered when the scale animation ends after a double tap.
321+
291322
### onVerticalPull
292323

293324
| Type | Default | Additional Info |
@@ -498,4 +529,4 @@ Reset all transformations to their initial state.
498529
| `direction` | `vertical \| horizontal` | Direction of the gallery. |
499530
| `isScrolling` | `boolean` | Whether the gallery is actively being scrolled. |
500531
| `scroll` | `number` | Current scroll value. |
501-
| `gallerySize` | `SizeVector<number>` | Width and height of the gallery. |
532+
| `gallerySize` | `Size<number>` | Width and height of the gallery. |

docs/docs/components/resumablezoom.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ Minimum scale value allowed by the pinch gesture, expects values greater than or
9898

9999
| Type | Default |
100100
| ------------------------------ | ------- |
101-
| `SizeVector<number> \| number` | `6` |
101+
| `Size<number> \| number` | `6` |
102102

103103
Maximum scale value allowed by the pinch gesture, expects values bigger than or equals one.
104104

105105
Alternatively you can pass the resolution of your image/video, for instance `{ width: 1920, height: 1080 }`;
106106
this will instruct the component to calculate `maxScale` in such a way it's a value just before your content
107-
starts to pixelate.
107+
starts pixelating.
108108

109109
### panMode
110110

@@ -200,6 +200,22 @@ Enables and disables both single and double tap gestures.
200200

201201
Callback triggered when the user taps the wrapped component once.
202202

203+
### onDoubleTapStart
204+
205+
| Type | Default | Additional Info |
206+
| ------------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------- |
207+
| `(e: TapGestureEvent) => void` | `undefined` | see [tap gesture event data](https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#event-data) |
208+
209+
Callback triggered when the user double taps.
210+
211+
### onDoubleTapEnd
212+
213+
| Type | Default | Additional Info |
214+
| ------------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------- |
215+
| `(e: TapGestureEvent) => void` | `undefined` | see [tap gesture event data](https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#event-data) |
216+
217+
Callback triggered when the scale animation ends after a double tap.
218+
203219
### onSwipe
204220

205221
| Type | Default |

docs/docs/components/snapbackzoom.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ All properties for this component are optional.
8282

8383
Increase (Android only) or decrease the gesture detection area around your component in all directions by a given amount in pixels, useful when dealing with small components.
8484

85+
### minScale
86+
87+
| Type | Default |
88+
| -------- | ------- |
89+
| `number` | `0` |
90+
91+
Minimum scale value allowed by the pinch gesture, expects values greater than or equals one.
92+
93+
### maxScale
94+
95+
| Type | Default |
96+
| ------------------------------ | ------- |
97+
| `Size<number> \| number` | `6` |
98+
99+
Maximum scale value allowed by the pinch gesture, expects values bigger than or equals one.
100+
101+
Alternatively you can pass the resolution of your image/video, for instance `{ width: 1920, height: 1080 }`;
102+
this will instruct the component to calculate `maxScale` in such a way it's a value just before your content
103+
starts pixelating.
104+
85105
### timingConfig
86106

87107
| Type | Default | Additional Info |

docs/docs/installation.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,29 @@ This library relies on both Reanimated and Gesture Handler making part of your p
99

1010
| React Native Version | React Native Zoom Toolkit Version | Gesture Handler version |
1111
| -------------------- | --------------------------------- | ----------------------- |
12-
| `<= 0.76` | `>= 3.0.0` | 2.16.0 and beyond. |
13-
| `>= 0.76` | `>= 4.0.0` | 2.19.0 and beyond. |
12+
| `<= 0.76` | `>= 3.0.0` | 2.16.0 and above. |
13+
| `>= 0.76` | `>= 4.0.0` | 2.19.0 and above. |
14+
| `>= 0.81` | `>= 6.0.0` | 2.19.0 and above. |
15+
16+
For Expo 54 and above.
17+
18+
::: code-group
19+
20+
```sh [npm]
21+
npm install react-native-zoom-toolkit react-native-gesture-handler react-native-reanimated react-native-worklets
22+
```
23+
24+
```sh [yarn]
25+
yarn add react-native-zoom-toolkit react-native-gesture-handler react-native-reanimated react-native-worklets
26+
```
27+
28+
```sh [expo]
29+
npx expo install react-native-zoom-toolkit react-native-gesture-handler react-native-reanimated react-native-worklets
30+
```
31+
32+
:::
33+
34+
For Expo 53 and below.
1435

1536
::: code-group
1637

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: useZoomCallbacks hook
3+
outline: deep
4+
---
5+
6+
# useZoomCallbacks hook
7+
8+
A simple utility for `ResumableZoom`, `CropZoom` and `Gallery` components to handle common zoom events such as
9+
10+
| Event Name | Description |
11+
|-------------------|------------------------------------------------------------------------------------|
12+
| onUpdate | Callback triggered every time scale is updated |
13+
| onStart | Callback triggered the very fist time scale value changes |
14+
| onEnd | Callback triggered once the scale value has returned to its base state |
15+
| onMaxScaleReached | Callback triggered once the scale value is greater than equals the max scale value |
16+
17+
## How to use
18+
19+
useZoomCallbacks is dependant on the zoom component's current state, therefore you need to use useTransformState hook in order to get such values.
20+
21+
```tsx {3}
22+
const {state, onUpdate} = useTransformationState("common")
23+
useZoomCallbacks(
24+
state,
25+
{
26+
onUpdate: (scale) => console.log("Current scale value ", scale),
27+
onStart: () => console.log("Zoom started"),
28+
onEnd: () => console.log("Zoom finished"),
29+
onMaxScaleReached: (scale) => console.log("Reached max scale at", scale)
30+
}
31+
)
32+
33+
<ResumableZoom onUpdate={onUpdate}>
34+
<Image />
35+
</ResumableZoom>
36+
```

docs/docs/utilities/usetransformationstate.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ your choice, for a hands on example see [How to use with Skia Components](../gui
1212

1313
When calling this hook you will receive the three following properties:
1414

15-
- `onUpdate` is a worklet function which must be passed as a property to the zoom component's onUpdate
15+
- `onUpdate` is a [worklet](https://docs.swmansion.com/react-native-reanimated/docs/guides/worklets/) which must be passed as a property to the zoom component's onUpdate
1616
callback property, this way the zoom component will update transform and state properties.
1717
- `transform` is a shared value describing zoom component's current transformations as an array.
18-
- `state` is an object holding the shared values describing the current transformation state, in case
19-
you need them.
18+
- `state` is an object holding the [Reanimated's shared values](https://docs.swmansion.com/react-native-reanimated/docs/2.x/fundamentals/shared-values/) describing the current transformation state in case you need them.
2019

2120
```tsx{9,21}
2221
import { useTransformationState } from 'react-native-zoom-toolkit';

0 commit comments

Comments
 (0)