meliorence / meliorence/react-native-snap-carousel

Orientation change with Parallax

Open
#785 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

Is this a bug report, a feature request, or a question?

Question

Hello all! I'm trying to implement a carousel with some images and be ale to render them. I've followed the steps and succeed implementing a Parallax carousel. But thing is, when I rotate the device, the imagen don't resize. I've tried everything I tried to reproduce the steps on the Tips Readme on how to handle rotation but no luck, I had to transform those instructions to SFC and Hooks but no luck.

Heres my code it's almost identical to the example, but trust me I've tried everything to fix this problem with no luck:

`
import React, { useRef, useState, useEffect } from 'react';
import Carousel, { ParallaxImage } from 'react-native-snap-carousel';
import { View, Dimensions } from 'react-native';
import style from './style';
import colors from '../../common/colors';

const ENTRIES1 = [
{
title: 'Beautiful and dramatic Antelope Canyon',
subtitle: 'Lorem ipsum dolor sit amet et nuncat mergitur',
illustration: 'https://i.imgur.com/UYiroysl.jpg',
},
{
title: 'Earlier this morning, NYC',
subtitle: 'Lorem ipsum dolor sit amet',
illustration: 'https://i.imgur.com/UPrs1EWl.jpg',
},
{
title: 'White Pocket Sunset',
subtitle: 'Lorem ipsum dolor sit amet et nuncat ',
illustration: 'https://i.imgur.com/MABUbpDl.jpg',
},
{
title: 'Acrocorinth, Greece',
subtitle: 'Lorem ipsum dolor sit amet et nuncat mergitur',
illustration: 'https://i.imgur.com/KZsmUi2l.jpg',
},
{
title: 'The lone tree, majestic landscape of New Zealand',
subtitle: 'Lorem ipsum dolor sit amet',
illustration: 'https://i.imgur.com/2nCt3Sbl.jpg',
},
];
const { width: screenWidth, height: screenHeight } = Dimensions.get('window');

const Photos = () => {
const [entries, setEntries] = useState([]);
const carouselRef = useRef(null);

useEffect(() => {
setEntries(ENTRIES1);
}, []);

const renderItem = ({ item }, parallaxProps) => {
return (

<ParallaxImage
source={{ uri: item.illustration }}
containerStyle={style.imageContainer}
style={style.image}
parallaxFactor={0.4}
{...parallaxProps}
showSpinner
spinnerColor={colors.red}
/>

);
};

return (



);
};

export default Photos;
`

So i looks like this when vertical:
Screenshot_1606512124

Pretty good, but when I rotate the device:

Screenshot_1606512134

Environment

Environment:
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-snap-carousel": "^3.9.1",

Target Platform:
Android (9.0)
iOS (13.0)

Thanks!!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied Photos component, especially the module-level Dimensions.get('window') values and the Carousel sizing props; reproduce rotation on the listed Android and iOS versions. Done means the carousel and parallax images resize correctly after orientation changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.