jones
jones

Reputation: 755

How to get Owl carousel current item in react js

How I get the current item selected in react-owl-carousel. I did use to get the id during translated event and also tried all events in official document. https://www.npmjs.com/package/react-owl-carousel BTW: how is possible to get the info: parmater(just like in Jquery) I am not able to get any response from this.

return <div className="rp-slider-main owl-carousel clearfix">
      <OwlCarousel className="owl-theme" loop={false} nav={false} autoWidth={false} items={1} center={false}  onChanged={() => handleSelect(e)}>
        {props.commentsArr.map((topComment, index) => (
            <div className=item key={index}>
        ..........
    </div>
     )}
     </OwlCarousel>
   </div>

And my event is

handleSelect(e) {var index = e.page.index;} 

here index does not change when user changes the slide item How do I get the current slide item id or least the slide #number,and want to make sure that I have selected the right event'onTranslated'.

Upvotes: 1

Views: 2756

Answers (1)

Vivek Gupta
Vivek Gupta

Reputation: 76

You will have to use onChanged event of it, it will give you current index

<OwlCarousel className="owl-theme" loop={true} nav={false} autoWidth={false} items={1} center={false} onChanged={() => props.handleSelect(e)} >

Upvotes: 2

Related Questions