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

Transparent background #575

Open
lutestringamend opened this issue Mar 23, 2024 · 2 comments
Open

Transparent background #575

lutestringamend opened this issue Mar 23, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@lutestringamend
Copy link

WhatsApp Image 2024-03-23 at 2 04 37 PM

Is there anyway to make the carousel container transparent? It always forces a white background container like this. Thank you!

Describe the bug
A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • react: v0.0.0
  • react-native: v0.0.0
  • react-native-reanimated: v0.0.0
  • react-native-reanimated-carousel: v0.0.0
  • react-native-gesture-handler: v0.0.0

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@lutestringamend lutestringamend added the bug Something isn't working label Mar 23, 2024
Copy link

dosubot bot commented Mar 23, 2024

Hey there, @lutestringamend! Fancy seeing you here again. How's it going?

Yes, you can make the carousel container in the react-native-reanimated-carousel transparent by modifying the style prop passed to the ScrollViewGesture component within your Carousel component. Specifically, you can add a backgroundColor with a value of 'transparent' to the style array for the ScrollViewGesture component.

Here's how you can modify the style prop:

<ScrollViewGesture
  key={mode}
  size={size}
  translation={handlerOffset}
  style={[
    styles.container,
    {
      width: width || "100%",
      height: height || "100%",
      backgroundColor: 'transparent', // Add this line
    },
    style,
    vertical
      ? styles.itemsVertical
      : styles.itemsHorizontal,
  ]}
  testID={testID}
  onScrollStart={scrollViewGestureOnScrollStart}
  onScrollEnd={scrollViewGestureOnScrollEnd}
  onTouchBegin={scrollViewGestureOnTouchBegin}
  onTouchEnd={scrollViewGestureOnTouchEnd}
>

By adding backgroundColor: 'transparent' to the style array, you override any default background color (such as white) that might be applied to the ScrollViewGesture component, making it transparent.

Please note that the react-native-reanimated-carousel component does not have a default background color set in its styles. The provided styles only include properties for overflow in container, and flexDirection for itemsHorizontal and itemsVertical. There is no mention of backgroundColor or any related property in the styles definition.

If you're still experiencing issues, could you please provide more information about your setup? Specifically, the versions of react, react-native, react-native-reanimated, react-native-reanimated-carousel, and react-native-gesture-handler you're using, as well as the device and OS you're testing on. This will help in diagnosing the issue.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@lutestringamend
Copy link
Author

I've tried this solution but the issue persists. Anything else I should modify?

<GestureHandlerRootView>
        <CTX.Provider value={{ props, common: commonVariables }}>
          <ScrollViewGesture
            key={mode}
            size={size}
            translation={handlerOffset}
            style={[
              styles.container,
              {
                width: width || "100%",
                height: height || "100%",
              },
              style,
              vertical
                ? styles.itemsVertical
                : styles.itemsHorizontal,
              {
                backgroundColor: "transparent",
              },
            ]}
            testID={testID}
            onScrollBegin={scrollViewGestureOnScrollBegin}
            onScrollEnd={scrollViewGestureOnScrollEnd}
            onTouchBegin={scrollViewGestureOnTouchBegin}
            onTouchEnd={scrollViewGestureOnTouchEnd}
          >
            {data.map(renderLayout)}
          </ScrollViewGesture>
        </CTX.Provider>
      </GestureHandlerRootView>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants