react-native-looped-carousel icon indicating copy to clipboard operation
react-native-looped-carousel copied to clipboard

Problem in dynamic content

Open krishbhattacharyya opened this issue 9 years ago • 10 comments

Thank you for sharing this.

When I tried to implement this dynamically I got problem.

This is the component ( Within the modal )- <Carousel style={this.props.size} autoplay = {false} currentPage ={this.props.currentPage} > { DynamicContent }</Carousel>

The popup is looks fine with the dynamic content. But it can't able to load the currentPage. And I need only the Carousel not loop. So if it is possible please add option to stop the loop. It will be better.

krishbhattacharyya avatar Oct 18 '16 13:10 krishbhattacharyya

@krishbhattacharyya Never thought about such use case, i'll try to add this functionality this week. P.S. PRs are always welcome ;)

phil-r avatar Oct 18 '16 16:10 phil-r

@krishbhattacharyya Also you can disable loop by setting autoplay prop to false

phil-r avatar Oct 18 '16 16:10 phil-r

@phil-r ... Thanks.... This is really helpful .... And I know about autoplay.... In { DynamicContent } is a render elements where I have passed array for content display in modal ..... I want to use like a touch slider carousel like facebook multiple images popup.... Already worked for me .... but only two issues left as told this earlier.

krishbhattacharyya avatar Oct 18 '16 17:10 krishbhattacharyya

@krishbhattacharyya Can you provide a simple example, illustrating your problem?

phil-r avatar Oct 18 '16 18:10 phil-r

@krishbhattacharyya I've fixed a bunch of bugs today and added a new example with Modal Can you check whether it fixes your problems?

phil-r avatar Oct 18 '16 20:10 phil-r

Thanks, I like you .... for temporary this is working fine. Tonight I will share you the demo & there is an error. If you solve this it will be great for me & also you can use in your modal.

krishbhattacharyya avatar Oct 19 '16 06:10 krishbhattacharyya

Due to some reason I could not upload my code ( Very Soon I upload it ): Please this is my code. Only the issue is - Popup elements render two times. I just want to render this : As per given data.

Thank you.

` /----------------------- Props set -------------/

this.state = { modalVisible: false, initArray: [], index:0 };

/----------------------- function Open close-------------/

showModal = (arr,ind) => { this.setState({ modalVisible: true }); this.setState({initArray: arr}); this.setState({index: ind}); }

hideModal = () => { this.setState({ modalVisible: false }); this.setState({initArray: []}); }

/----------------------- Content element function-------------/

var DynamicContent = this.state.initArray.map(function(list) { return ( <View style={{ flex:1}} key={list.id}> <View style={{flex:1, width:width, alignItems:'center', justifyContent:'center',}}> <Image source={{uri: list.imgUrl}} style={{ width: null, alignSelf: 'stretch', flex: 1, resizeMode: 'contain' }} /> </View> </View> ); });

/----------------------- Modal ------------------------------/ <Modal animationType={'slide'} transparent={false} visible={this.state.modalVisible}

    >
     <TouchableHighlight onPress={this.hideModal} >
      <Text>Hide Modal</Text>
     </TouchableHighlight>
      <Carousel
        delay={2000}
        style={{ flex: 1 }}
        autoplay={false}
        pageInfo
        currentPage={this.state.index}
        onAnimateNextPage={(p) => console.log(p)}
      >

         { DynamicContent }
      </Carousel>
    </Modal>

/----------------------- Calling the array ------------------------------/ <TouchableHighlight onPress={() => this.showModal([ { 'id':'1', 'imgUrl':'http://images.freeimages.com/images/previews/8e8/working-early-3-1514654.jpg', 'pageNo':'1' }, { 'id':'2', 'imgUrl':'http://images.freeimages.com/images/previews/837/medical-06-1455841.jpg', 'pageNo':'2' }, { 'id':'3', 'imgUrl':'http://images.freeimages.com/images/previews/c20/contrasts-1422295.jpg', 'pageNo':'3' }, { 'id':'4', 'imgUrl':'http://images.freeimages.com/images/previews/c47/film-4-1457180.jpg', 'pageNo':'4' }, { 'id':'5', 'imgUrl':'http://images.freeimages.com/images/previews/4ff/glow-tubes-1426203.jpg', 'pageNo':'5' }],3)} > <Text>Show Modal</Text> </TouchableHighlight> <TouchableHighlight onPress={() => this.showModal([ { 'id':'1', 'imgUrl':'http://images.freeimages.com/images/previews/356/goldenhorn-1391126.jpg', 'pageNo':'1' }, { 'id':'2', 'imgUrl':'http://images.freeimages.com/images/previews/a35/the-sea-1362453.jpg', 'pageNo':'2' }, { 'id':'3', 'imgUrl':'http://images.freeimages.com/images/previews/869/duck-1403662.jpg', 'pageNo':'3' }],1)} > <Text>Show Modal2</Text> </TouchableHighlight> ` modal1 modal2

krishbhattacharyya avatar Oct 20 '16 04:10 krishbhattacharyya

Sorry for late reply @phil-r . This is my repo... https://github.com/krishbhattacharyya/Modal Everything is working fine except one thing. Images arrays are duplicating when render. Can I stop this? I want to display only images which define on arrays.

krishbhattacharyya avatar Oct 24 '16 04:10 krishbhattacharyya

Hi @phil-r , I am waiting for your reply. Can you help me to stop the loop?

krishbhattacharyya avatar Oct 31 '16 04:10 krishbhattacharyya

+1

stief510 avatar Feb 01 '17 22:02 stief510