How can we help you today?

How to Add Play/Pause Functionality to the Slideshows Design Element

If you have a Slideshow Design Element on your page with the Autoplay option enabled, you might want to add a Play/Pause functionality so that users can focus on certain items for as long as they want. 


Pause / Play


TABLE OF CONTENTS


Prerequisites


Step-by-step Tutorial

The steps have been divided into three parts. Follow all three parts to learn how to add the play/ pause functionality to the Slideshow Design Element.


Part 1: Add Class Name to the Slideshow Design Element

This part of the tutorial will demonstrate how to add a class name to the Slideshow Design Element. Start the interactive tutorial or follow the steps below:



Step 1: Edit the SharePoint web part

  • Go to the SharePoint page you want to use and click Edit.


Edit


  • Click the ShortPoint tag.
  • Select the pencil icon.

Step 2: Edit the Slideshow Design Element


NOTEBefore proceeding, make sure you already have the Slideshow Design Element on your page.


  • Click the Slideshow tag.
  • Select the cogwheel icon.

Step 3: Add Class Name

  • Navigate to the Custom CSS tab.
  • Add the Class Name you prefer. Make sure to remember this as you will use this in the next parts.
  • Click the green checkmark.

Part 2: Add Class Name to the Buttom Design Element

This part will demonstrate how to insert and customize the Button Design Element, as well as, assign a Class Name. Start the interactive tutorial or follow the steps below:



Step 1: Insert the Button Design Element

  • Click the pink plus icon.


pink plus icon


  • Use the search bar to look for the Button Design Element and click it.

Step 2: Customize the Button Design Element

  • Modify the button Title. For this guide, we will name the button “Pause”.
  • Add a button Icon. For this guide, we will use the pause icon.
  • Navigate to the Design tab.
  • Modify the look of the button according to your preference.

Step 3: Add Class Name

  • Navigate to the Custom CSS tab.
  • Add the Class Name you prefer. Make sure that is different from the class name you added for the Slideshow Design Element.
  • Click the green checkmark.

Part 3: Add the Custom Javascript

This part will demonstrate how to add the custom Javascript. To get started, click the interactive tutorial or follow the detailed instructions.


Before proceeding with the interactive tutorial below, copy this Javascript:


shortpoint.$( document ).ready(function() {
  var $button = shortpoint.$('.playPauseBtn');
  var $slider = shortpoint.$('.pausableSlider');
  var $icon = $button.find('i');
  
  function playSlider() {
    $slider.slick('play');
    $button.text(' Pause');
    $button.prepend($icon);
    $icon.addClass('shortpoint-icon-fa-pause');
    $icon.removeClass('shortpoint-icon-fa-play');  
    $button.one('click', pauseSlider);
  }
  
  function pauseSlider() {
    $slider.slick('pause');
    $button.text(' Play');
    $button.prepend($icon);
    $icon.removeClass('shortpoint-icon-fa-pause');
    $icon.addClass('shortpoint-icon-fa-play');  
    $button.one('click', playSlider);
  }
  
  $button.one('click', pauseSlider);  
});



Step 1: Insert the Code Design Element

  • Click the Switch to Grid Mode icon.


Switch to Grid Mode icon


  • Select the gray plus icon.


Gray plus icon


  • Use the search bar to look for the Code Design Element and click it.

Step 2: Copy the Javascript

  • Copy the Javascript code below:


shortpoint.$( document ).ready(function() {
  var $button = shortpoint.$('.playPauseBtn');
  var $slider = shortpoint.$('.pausableSlider');
  var $icon = $button.find('i');
  
  function playSlider() {
    $slider.slick('play');
    $button.text(' Pause');
    $button.prepend($icon);
    $icon.addClass('shortpoint-icon-fa-pause');
    $icon.removeClass('shortpoint-icon-fa-play');  
    $button.one('click', pauseSlider);
  }
  
  function pauseSlider() {
    $slider.slick('pause');
    $button.text(' Play');
    $button.prepend($icon);
    $icon.removeClass('shortpoint-icon-fa-pause');
    $icon.addClass('shortpoint-icon-fa-play');  
    $button.one('click', playSlider);
  }
  
  $button.one('click', pauseSlider);  
});

Step 3: Copy the Javascript

  • Paste the Javascript code in the Javascript field.
  • Replace playPauseBtn with the Class Name you added for the Button Design Element.


playPauseBtn

  • Replace pausableSlider with the Class Name you added for the Slideshow Design Element.


pausableSlider


  • Scroll down and disable Sandbox mode.


Sandbox mode


Step 4: Insert and Save

  • Click Insert.
  • Click the eye icon to see your page in real-time.


eye icon


  • Click Save to apply your changes.


Save


Congratulations! You can now pause/play the Slideshow Design Element.


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 69 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more