Open dhill1 opened 7 years ago
I am having the same issue when loading the slides from an array, where an additional blank element is added. My implementation is similar to the above.
@dhill1 Did you fix it or find a work around ?
@ijosorio1022 no I was not able to solve this one
Here is how I solved this issue (for Meteor + React Project) - OwlCarousel.js adds the empty slide not the React part of it.
Remove react-owl-carousel from your project
Download the react-owl-carousel zip package from git and extract it to temporary location
From the 'components' folder of the extracted content, copy the OwlCarousel.jsx to your project
Download the latest OwlCarousel.js (https://owlcarousel2.github.io/OwlCarousel2/docs/started-welcome.html)
Extract the zip file to temporary location then copy the OwlCarousel.js to your project
While you are there you can also copy the css files to your project
Open the OwlCarousel.js from your project and go to 'Owl.prototype.replace = function(content) {' (should be around line 1289)
In that function find '}).each($.proxy(function(index, item) {'
Add the following code just under this.$stage.append(item); ``
let i = item[0].children[0];
let clsNm;
if(i){
clsNm = $(i).attr('class');
}
if(clsNm !== 'owl-stage') {
this._items.push(item);
}
Don't forget to change 'import' statements to the OwlCarousel.jsx that is in your project
In all fairness I did not do a lot of testing with this change but it seems to work perfectly good.
It's work.
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>
);
}.bind(this))
);
}
}.bind(this));
And the length checking should be {ImageList.length>0? <OwlCarousel {...options} className="owl-theme" > {ImageList} :""}
i solve this in react-owl-carousel just using this css property .owl-item.active:first-child { display: none; } this is my setup
return(
<div className='item' key={art.id}>
<div className="center-crop">
<a href="" className="category-link">
<span className="label-warning">{art.categories.peek().name}</span>
</a>
<Link to={`/articulo/${art.permalink}`}>
<img src={methods.checkmedia(art)} alt={art.title} className='img-carousel'/>
</Link>
<div className="carousel-link">
<Link to={`/articulo/${art.permalink}`}>
{art.title}
</Link>
</div>
</div>
{methods.checkVideoArticle(art)}
<div className="newSummary">
{art.highlight}
</div>
</div>)
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>
:""}
i solve this in react-owl-carousel just using this css property .owl-item.active:first-child { display: none; } this is my setup
return( <div className='item' key={art.id}> <div className="center-crop"> <a href="" className="category-link"> <span className="label-warning">{art.categories.peek().name}</span> </a> <Link to={`/articulo/${art.permalink}`}> <img src={methods.checkmedia(art)} alt={art.title} className='img-carousel'/> </Link> <div className="carousel-link"> <Link to={`/articulo/${art.permalink}`}> {art.title} </Link> </div> </div> {methods.checkVideoArticle(art)} <div className="newSummary"> {art.highlight} </div> </div>)
this solution fix my problem.
I seem to be getting a blank slide at the end when using a dynamic array to generate my slides.
I have verified that my array only returns 4 results, but the carousel is generating 5 items with a blank one at the end.