asNavFor works for all items expect first one
See original GitHub issueI am attempting to use the asNavFor
prop.It works when I click on any of the cells besides the first one. However, when I click on the first item in the “nav slider” the first slider doesn’t move.
Has anyone else had this issue?
Code (Removed Some for readability):
class Listings extends Component {
state = {
mainSlider: undefined,
navSlider: undefined
}
componentDidMount() {
this.setState({
mainSlider: this.mainSlider,
navSlider: this.navSlider
})
}
render() {
const { pageData } = this.props
const styles = configurableStyles(pageData)
const {
listingsTitle,
listings,
} = pageData
const mainSettings = {
accessibility: true,
autoplay: true,
autoplaySpeed: 10000, //10s
arrows: false,
dots: false,
infinite: listings && listings.length > 6,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
responsive: [{
breakpoint: 650,
settings: {
infinite: listings && listings.length > 4,
}
}],
className: 'no-dots',
ref: (slider) => (this.mainSlider = slider),
asNavFor: this.state.navSlider
}
const navSettings = {
accessibility: true,
autoplay: true,
autoplaySpeed: 10000, //10s
arrows: false,
dots: true,
infinite: listings && listings.length > 6,
speed: 500,
slidesToShow: 6,
slidesToScroll: 1,
focusOnSelect: true,
responsive: [{
breakpoint: 650,
settings: {
infinite: listings && listings.length > 4,
slidesToShow: 4,
}
}],
//className : 'slick-left-align',
ref: (slider) => (this.navSlider = slider),
asNavFor: this.state.mainSlider,
}
return (
<div style={styles.listingsSection} id='listingsSection'>
<h2 style={styles.listingsTitle}>{listingsTitle}</h2>
<div style={styles.listingsWrapper}>
<Slider {...mainSettings}>
{listings && listings.map((cell, cellIndex) => {
const { price, address, bed, bath, thumbnail } = cell
return (
<div key={`cell_${cellIndex}`}>
{...}
</div>
)
})}
</Slider>
<Slider {...navSettings}>
{listings && listings.map((cell, cellIndex) => {
const { address, thumbnail } = cell
return (
<div key={`nav_cell_${cellIndex}`}>
{...}
</div>
)
})}
</Slider>
</div>
</div>
)
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Slick.Js asNavFor Resetting to First Slide Each Time
I have two carousels, both have five slides, with the top carousel showing one slide at a time and the bottom showing all...
Read more >5. Working with Arrays and Loops - JavaScript Cookbook [Book]
Arrays in JavaScript are zero-based, which means the first element index is zero, and the last ... Not all array elements have to...
Read more >Sync iPod touch with your computer - Apple Support
Select Sync to turn on syncing for that type of item. By default, all items of a content type are synced, but you...
Read more >Repair sync connections in OneDrive for work or school
Many errors can be fixed by using the Repair option in the OneDrive menu that you can ... Sometimes, you might prefer to...
Read more >sync [Zotero Documentation]
While Zotero stores all data locally on your computer by default, ... Data syncing syncs library items, but doesn't sync attached files ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am experiencing the same problem. I can see that it works when loop is enabled ( because in that case the first slide is always the active slide), but its on the false loop that i would need it to work
Hi, just render the slide with onClick and manually change the slide to 0 index with SlickGoTo. I came up with this its working fine
Note: If haven’t added any condition for 0th index its working fine with onclick also.
Here my code: onClick={()=>{ this.nav1.slickGoTo(0); }}