Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] Fix incorrect startX and startY values in Pan #2871

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Apr 19, 2024

Description

After solving #2868 it was found out that manualActivation may result in wrong translation values. The problem here is that onPointerDown method doesn't set startX and startY value. What is important, these values are also assigned in resetProgress method.

Without manual activation, handler first calls onPointerDown, and then resetProgress, therefore values of startX and startY are correct. On the other hand, in the snippet below handler first calls resetProgress and then onPointerDown, that's why both startX and startY are still 0.

Test plan

Tested on the following code mentioned in #2868

Test code
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import Animated, {
  useAnimatedStyle,
  useSharedValue,
} from 'react-native-reanimated';

export default function App() {
  const left = useSharedValue(0);

  const panGesture = Gesture.Pan()
    .manualActivation(true)
    .onTouchesDown((e, stateManager) => {
      stateManager.activate();
    })
    .onUpdate((e) => {
      console.log(e.translationX);
      left.value = e.translationX;
    });

  const animatedStyle = useAnimatedStyle(() => {
    return {
      transform: [{ translateX: left.value }],
    };
  });

  return (
    <View style={styles.container}>
      <GestureDetector gesture={panGesture}>
        <Animated.View style={[styles.square, animatedStyle]} />
      </GestureDetector>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'yellow',
  },
  square: {
    top: 150,
    height: 100,
    width: 100,
    backgroundColor: 'red',
  },
});

@m-bert m-bert requested a review from j-piasecki April 19, 2024 09:37
@m-bert m-bert merged commit 052e3a1 into main Apr 19, 2024
1 check passed
@m-bert m-bert deleted the @mbert/fix-translateX-web branch April 19, 2024 09:54
github-merge-queue bot pushed a commit to valora-inc/wallet that referenced this pull request Jun 6, 2024
…5520)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler)
| [`^2.16.0` ->
`^2.16.2`](https://renovatebot.com/diffs/npm/react-native-gesture-handler/2.16.0/2.16.2)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-native-gesture-handler/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-native-gesture-handler/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-native-gesture-handler/2.16.0/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-native-gesture-handler/2.16.0/2.16.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>software-mansion/react-native-gesture-handler
(react-native-gesture-handler)</summary>

###
[`v2.16.2`](https://github.com/software-mansion/react-native-gesture-handler/releases/tag/2.16.2)

[Compare
Source](https://github.com/software-mansion/react-native-gesture-handler/compare/2.16.1...2.16.2)

##### 🐛 Bug fixes

- Revert "Change `.web` files to default and add `.native`
([#&#8203;2835](https://github.com/software-mansion/react-native-gesture-handler/issues/2835))"
by [@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2896

##### 🔢 Miscellaneous

- Add examples to Gestures section in docs by
[@&#8203;xnameTM](https://github.com/xnameTM) in
[software-mansion/react-native-gesture-handler#2876
- Fix missing styles in gestures' InteractiveExamples by
[@&#8203;patrycjakalinska](https://github.com/patrycjakalinska) in
[software-mansion/react-native-gesture-handler#2897

**Full Changelog**:
software-mansion/react-native-gesture-handler@2.16.1...2.16.2

###
[`v2.16.1`](https://github.com/software-mansion/react-native-gesture-handler/releases/tag/2.16.1)

[Compare
Source](https://github.com/software-mansion/react-native-gesture-handler/compare/2.16.0...2.16.1)

#### 🐛 Bug fixes

- Fix remote debugger detection in bridgeless mode by
[@&#8203;piaskowyk](https://github.com/piaskowyk) in
[software-mansion/react-native-gesture-handler#2864
- Fix `manualActivation` on web by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2869
- Fix old Gesture Handler API integration with Reaniamted by
[@&#8203;piaskowyk](https://github.com/piaskowyk) in
[software-mansion/react-native-gesture-handler#2881
- \[Web] Fix incorrect `startX` and `startY` values in `Pan` by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2871
- \[Web] Add `minVelocity` to `Pan` custom activation criteria by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2884

#### 👍 Improvements

- Add `TypeDoc` to new API by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2874

#### 🔢 Miscellaneous

- Bump Gesture Handler version in documentation by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2838
- Change `.web` files to default and add `.native` by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2835
- Bump `typescript` version in example by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2848
- Disable flipper on CI by [@&#8203;m-bert](https://github.com/m-bert)
in
[software-mansion/react-native-gesture-handler#2843
- Update supported RN versions by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2849
- Add state flow charts to Gesture Handler's documentation. by
[@&#8203;latekvo](https://github.com/latekvo) in
[software-mansion/react-native-gesture-handler#2817
- Fix `cancell` typo by [@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2854
- Minor TS changes by [@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2872
- Add automatic og:image generation to docs by
[@&#8203;xnameTM](https://github.com/xnameTM) in
[software-mansion/react-native-gesture-handler#2851
- Fix typo in og:image generation by
[@&#8203;kacperkapusciak](https://github.com/kacperkapusciak) in
[software-mansion/react-native-gesture-handler#2880
- Bump React Native in FabricExample to 0.74 by
[@&#8203;m-bert](https://github.com/m-bert) in
[software-mansion/react-native-gesture-handler#2877
- Update yarn setup in the repository by
[@&#8203;j-piasecki](https://github.com/j-piasecki) in
[software-mansion/react-native-gesture-handler#2882
- Release 2.16.1 by
[@&#8203;j-piasecki](https://github.com/j-piasecki) in
[software-mansion/react-native-gesture-handler#2883

#### New Contributors

- [@&#8203;xnameTM](https://github.com/xnameTM) made their first
contribution in
[software-mansion/react-native-gesture-handler#2851

**Full Changelog**:
software-mansion/react-native-gesture-handler@2.16.0...2.16.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone
America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone
America/Los_Angeles.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/valora-inc/wallet).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zODguMSIsInVwZGF0ZWRJblZlciI6IjM3LjM4OC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJucG0iLCJyZW5vdmF0ZSJdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: valora-bot <valorabot@valoraapp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants