Shopify Tips: How To Enable Autoplay on the Narrative Theme’s Slideshow

We recently completed an awesome eCommerce site for a great client over at Noosa & Co. Seriously go and check them out because they make some really cool beds right here on the Sunshine Coast. Anyways, we were really happy with Shopify’s ‘Narrative’ theme as it prefectly suited Noosa & Co’s image. The only problem was the slideshow – it needed to be manually clicked through and the buttons to change slides are pretty innocent:

Anyways to cut a long story short, in order to make the slideshow autplay you’ll need to follow these instructions:

  1. Click Online Store and then Themes
  2. Next, click on the Actions drop-down.
  3. From the drop-down, select Edit Code (as shown here). 
  4. Find the Assets folder and then open up the custom.js file.
  5. Once you open the custom.js file, you will just need to copy and paste the below code. Here is a quick screenshot to show you where to paste the code. 
var sections = window.theme.sections;
var slideshowAutoExtension = {
  init: function() {
    this.on('slideshow_desktop_init_done', this._autoplaySlideshow.bind(this));
  },
  _autoplaySlideshow: setInterval(function() {
    var $slide = $('.slideshow__slide--active')
                   .removeClass('slideshow__slide--active');

    var $button = $('.slideshow__button--active')
                   .removeClass('slideshow__button--active');

    var $slides = $('.slideshow__slide');

    var currentIndex = ($slides.index($slide) + 1) % $slides.length;

    $slides
      .eq(currentIndex)
      .addClass('slideshow__slide--active');

    var $buttons = $('.slideshow__button')
      .eq(currentIndex)
      .addClass('slideshow__button--active');

  }, 10000)

};

sections.extend('slideshow', slideshowAutoExtension);

A Note For The Geeks

On the third last line of the above code, where it says “10000” in green, this is where you can change the speed of the slideshow. Javascript works in milliseconds and the current “10000” entry equals to 10 seconds. If you would like to change it to a speed of 5 seconds, for example, make sure to change the code to “5000” instead.

9 thoughts on “Shopify Tips: How To Enable Autoplay on the Narrative Theme’s Slideshow”

  1. Hi, thanks for tipp.

    Could you help me with the Narrative Theme also?
    The video doesnt play on mobile devices.
    i can also pay for it if necessary.

    Kind regards
    peter

  2. it does work!thx!from japan
    i would like to change images more slowly and add zooming-up of the image effects.
    do you have any ideas or codes?

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top