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.

asNavFor works for all items expect first one

See original GitHub issue

I 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:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
kskoneckacommented, Aug 8, 2018

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

1reaction
hgsaazcommented, Jun 11, 2019

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); }}

Read more comments on GitHub >

github_iconTop 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 >

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