question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

extra blank slide when using array

See original GitHub issue

I seem to be getting a blank slide at the end when using a dynamic array to generate my slides.

import React, {PropTypes} from 'react'
import OwlCarousel from 'react-owl-carousel'

class Carousel extends React.Component {

    constructor(props) {
        super(props);

        this.options = {
            autoplay: true,
            loop: true,
            nav:true,
        }

    }


    render() {
        return (<OwlCarousel className="owl-theme" {...this.options}>
            {this.props.slideItems.map((item, idx) => {
                        let image = <img src={item.src} alt={item.alt ? item.alt : `Carousel Image #${idx}`} className={'image' + idx}/>
                        return (
                            <a key={idx} href={item.href} style={slideStyle} data-event={item.dataEvent} data-value={item.dataValue}>
                                {image}
                            </a>
                        )
                    })}
        </OwlCarousel>)
    }

}

export default Carousel

I have verified that my array only returns 4 results, but the carousel is generating 5 items with a blank one at the end.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:9

github_iconTop GitHub Comments

23reactions
GaneshMitracommented, Nov 15, 2017

I am having the same issue, I was resolved it by checking array length code as follows: ```

let ImageList = $.map(this.state.data, function (data, index) {
            if (parseInt(this.state.selectedcaseitem) === parseInt(index)) {
                return (
                    $.map(data.screenshots, function (d, i) {
                        return (
                            <span className="item" key={i}>
                                <img src={d.screenshot} alt="" />
                            </span>
                        );
                    }.bind(this))

                );
            }
        }.bind(this));
And the length checking should be 
                                  <span className="large-12 columns">
                                    {ImageList.length>0?
                                    <OwlCarousel {...options} className="owl-theme" >
                                        {ImageList}
                                    </OwlCarousel>:""}
                                </span>
12reactions
floyd0987commented, Apr 17, 2018

Checking the array length works.

{this.state.posts.length>0?
        <OwlCarousel ref="car" options={options} events={events}>

          {this.state.posts.map( (post) => 

               <div>
               <a href={ post.link }>
               <img src={ post.image } alt={ post.name } className="post-image" />
               <p>{ post.name }</p>
               </a>
               </div>

         )
       }

          </OwlCarousel>
          :""}
Read more comments on GitHub >

github_iconTop Results From Across the Web

extra blank slide when using array · Issue #17 - GitHub
I have verified that my array only returns 4 results, but the carousel is generating 5 items with a blank one at the...
Read more >
angular-carousel adds extra empty slide at end of carousel
I'm using a directive to set the height of the carousel to the tallest image, but it has the same issue whether or...
Read more >
extra blank slide keeps appearing in powerpoint manual ...
After every few slides there appears a blank slide which I have to navigate through with an extra click.
Read more >
Flexslider empty slide - WordPress Stack Exchange
I'm using flexslider with wp and my slider have 2 slides in view as one, the problem is when i have Steady number...
Read more >
Swiper API
Additional required wrapper --> <div class="swiper-wrapper"> <! ... If false , then the only way to switch the slide is use of external...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found