0

Hi I am working on SPFx image carousel web-part using react responsive carousel.

I want that if user click on image on carousel it will show detail description of image in modal dialog on same page:

public render(): React.ReactElement<IReactCarouselProps> {
  return (
   <div className={styles.reactCarousel}> 
        <Carousel showThumbs={false} autoPlay={true} >    
          {this.state.items.map((imageList) => {    
            return (<div>    
              <img src={imageList.Image["Url"]} /> 
              <p className="legend">{imageList.Title}</p>   
            </div>)    
          })}    
        </Carousel>    
        <div>
         {this.state.items1.map((description) => {    
           return (<div> 

               <div  dangerouslySetInnerHTML={{__html: description.Body}} />
           </div>)    
         })}  
         </div> 
      </div>    
 ); 
}

1 Answer 1

1

You can use onClickItem attribute of Carousel to right your own function to show the details of clicked image from carousel. you can add it on carousel like:

<Carousel showThumbs={false} onClickItem={_onClickItem} autoPlay={true} >    
    {this.state.items.map((imageList) => {    
        return (<div>    
                    <img src={imageList.Image["Url"]} /> 
                    <p className="legend">{imageList.Title}</p>   
                </div>)    
        })
    }    
</Carousel> 

function _onClickItem() {
    console.log('onClickItem', arguments);
}

Check the implementation of there at: react-responsive-carousel.

NPM Package Reference: React Responsive Carousel.

And to show the modal pop-up you can use any one of the modal popups in React JS:

React Modals.

Personally I liked the Modal-React Bootstrap.

7
  • Actually this is a very broad question. Even though I have given some hints and references to look upon. Have you tried this? Is it working for you? Commented Sep 24, 2019 at 13:05
  • i have not tried it but it give me idea from where to start i will let you know the output,i thought of using modal dialog of office farbic for pop up .
    – kumar
    Commented Sep 25, 2019 at 2:09
  • Sure, let me know if there is any issues. Commented Sep 25, 2019 at 5:35
  • This is just to follow up on this question. Have you tried this? Commented Sep 30, 2019 at 7:51
  • 1
    yes I am working on this and will update soon
    – kumar
    Commented Sep 30, 2019 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.