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

[bug]: Swipe card on X axis will cause window to scroll when Youtube iframe is playing #2200

Open
1 of 5 tasks
juniorforlife opened this issue Sep 19, 2023 · 3 comments
Open
1 of 5 tasks
Labels
template: bug This issue might be a bug type: needs repro Needs minimal reproduction

Comments

@juniorforlife
Copy link

Which react-spring target are you using?

  • @react-spring/web
  • @react-spring/three
  • @react-spring/native
  • @react-spring/konva
  • @react-spring/zdog

What version of react-spring are you using?

9.7.3

What's Wrong?

I have this config for @react-spring/web and @use-gesture/react to implement swiping card animation

const [animatedProps, animatedApi] = useSpring(() => ({
    from: { x: 0, rot: 0 },
    onRest: (e) => {
      callApi();
    },
  }));

  const gestureProps = useGesture(
    {
      onDrag: ({ movement: [mx] }) => {
        if (dragEnabled.current) {
          animatedApi.start(() => ({
            x: mx,
            rot: Math.max(Math.min(mx / 10, 2), -2), // limit to -2deg and 2deg
            config: { friction: 50, tension: 600 },
          }));
        }
      },
      onDragEnd: ({ movement: [moveX] }) => {
        if (dragEnabled.current) {
          const shouldFlyOut = Math.abs(moveX) > 120;
          const direction = moveX > 0 ? 1 : -1; // 1 = right, -1 = left
          animatedApi.start(() => ({
            x: shouldFlyOut ? outOfScreenDistance.current * direction : 0,
            rot: 0,
            config: { duration: 500 },
          }));
        }
      },
    },
    { drag: { preventScroll: true } }
  );

return <animated.div
      className={`absolute h-full w-full`}
      {...gestureProps()}
      style={{
        x: animatedProps.x,
        transform: animatedProps.rot
          .to([-12, 12], [-12, 12])
          .to((value: any) => `rotateZ(${value}deg)`),
        zIndex,
        touchAction: "none",
      }}
>
<YoutubeIframe />
</animated.div>

The swipe animation works just fine but when I play the Youtube iframe and swipe to the far right, my screen scrolls as well. I set overflow-hidden but it still doesn't fix it.

To Reproduce

Play the Youtube video and start swipe gesture to the far right

Expected Behaviour

No screen scrolling

Link to repo

Please see code above

@juniorforlife juniorforlife added the template: bug This issue might be a bug label Sep 19, 2023
@joshuaellis joshuaellis added the type: needs repro Needs minimal reproduction label Sep 19, 2023
@joshuaellis
Copy link
Member

Can you provide a codesandbox, it seems this YoutubeIframe is important to the bug you're experiencing and therefore it's important to have all the relevant information.

@juniorforlife
Copy link
Author

juniorforlife commented Sep 24, 2023

Can you provide a codesandbox, it seems this YoutubeIframe is important to the bug you're experiencing and therefore it's important to have all the relevant information.

Sorry for the late reply. I just got back from a vacation. While trying to provide codesandbox, I realize the overflow-scroll issue happens even without the iframe. Meaning when I swipe the card, page scrolling will happen even if I set overflow to hidden.
The issue happens with the example repo as well https://codesandbox.io/s/to6uf

Screen.Recording.2023-09-24.at.23.04.42.mov

@juniorforlife
Copy link
Author

@joshuaellis hello do you have any idea what this happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
template: bug This issue might be a bug type: needs repro Needs minimal reproduction
Projects
None yet
Development

No branches or pull requests

2 participants